[CLOSED] How to hide empty ToolTip?

  1. #1

    [CLOSED] How to hide empty ToolTip?

    Hi,

    Is it possible not to display an empty ToolTip? Here's the setup on my page. If the DisplayField1 element is empty, I'd like to prevent the ToolTip from showing up. It should be available if a non-empty value does exist though.

    <ext:DisplayField ID="DisplayField1" runat="server">
        <ToolTips>
            <ext:ToolTip ID="ToolTip1" runat="server">
                <Listeners>
                    <Show Fn="showToolTip" />
                </Listeners>
            </ext:ToolTip>
        </ToolTips>
    </ext:DisplayField>
    
    var showToolTip = function () {
        this.body.dom.innerHTML = "<b>" + DisplayField1.getValue() + "</b>";
    };
    Last edited by Daniil; Sep 17, 2012 at 5:44 AM. Reason: [CLOSED]
  2. #2
    Hi Vadym,

    Returning false from a BeforeShow prevents Tooltip appearing.

    There is an old bug.
    http://www.sencha.com/forum/showthread.php?111449

    To avoid it, please force Tooltip rendering. To do it you can call
    Tooltip.render(Ext.getBody());
    within a ResourceManager DocumentReady listener.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Vadym,

    Returning false from a BeforeShow prevents Tooltip appearing.

    There is an old bug.
    http://www.sencha.com/forum/showthread.php?111449

    To avoid it, please force Tooltip rendering. To do it you can call
    Tooltip.render(Ext.getBody());
    within a ResourceManager DocumentReady listener.
    Thanks much Danill! It works well with the bug fix you've provided. I did see a few suggestions to use BeforeShow in other threads, but it wouldn't work without the fix.
            var showToolTip = function () {
                this.body.dom.innerHTML = "<b>" + DisplayField1.getValue() + "</b>";
            };
    
            var onBeforeShow = function () {
                if (DisplayField1.getValue() == "") {
                    //toolTip.body.dom.innerHTML = null;
                    return false;
                }
            };
    
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="X">
          <Listeners>
              <DocumentReady Handler="/*Bug fix*/ToolTip1.render(Ext.getBody());" />
          </Listeners>
    </ext:ResourceManager>
    
    <ext:DisplayField ID="DisplayField1" runat="server">
    	<ToolTips>
    		<ext:ToolTip ID="ToolTip1" runat="server">
    			<Listeners>
    				<Show Fn="showToolTip" />
    				<BeforeShow Handler="return onBeforeShow();" />
    			</Listeners>
    		</ext:ToolTip>
    	</ToolTips>
    </ext:DisplayField>
    ToolTip1 is the ID of a ToolTip control. I believe it needs to be done for every ToolTip control on the page to use BeforeShow as suggested.
    You can mark this thread as resolved.
  4. #4
    Quote Originally Posted by vadym.f View Post
    I believe it needs to be done for every ToolTip control on the page to use BeforeShow as suggested.
    I think you are right.

Similar Threads

  1. [CLOSED] Hide tooltip
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 19, 2012, 1:45 PM
  2. [CLOSED] Hide grid tooltip when there is no text
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 25, 2011, 12:16 PM
  3. [CLOSED] GridPanel Cell Tooltip - javascript error on this.hide()
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 16, 2011, 12:22 PM
  4. [CLOSED] label.Hide() does not hide FieldLabel
    By alexp in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 12, 2010, 9:05 PM
  5. Replies: 0
    Last Post: Jun 26, 2009, 11:32 AM

Tags for this Thread

Posting Permissions