Client-side: set content to DOM element.

2 posts, 0 answers
  1. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 20 Apr 2009 Link to this post

    Hi,

    Using version 2009 Q1 SP1 (2009.1.402.35), I'm trying to dynamically set the content of a tooltip created from the ToolTipManager Client API to some DOM element. I get the following error when calling set_contentElement(): "this._contentCell is null".

    Here is a sample code to reproduce the problem :

    1 <script type="text/javascript"
    2    Sys.Application.add_load(function() { 
    3       window.toolTipManager = $find("<%= RadToolTipManager1.ClientID %>"); 
    4    }); 
    5  
    6    function PopupTooltipManager(anchor) 
    7    { 
    8       if (!window.toolTipManager) { 
    9          return; 
    10       } 
    11          
    12       //Find the tooltip for this element if it has been created 
    13       var tooltip = toolTipManager.getToolTipByElement(anchor); 
    14          
    15       //Create a tooltip if no tooltip exists for such element 
    16       if (!tooltip) { 
    17          tooltip = toolTipManager.createToolTip(anchor); 
    18           
    19          var contentElement = document.createElement('SPAN');   
    20          contentElement.innerHTML = 'Testing' 
    21          tooltip.set_contentElement(contentElement); 
    22       } 
    23  
    24       //show the tooltip 
    25       tooltip.show(); 
    26    } 
    27 </script> 
    28  
    29  
    30 <div onclick="PopupTooltipManager(this);">Create tooltip from manager</div> 
    31  
    32 <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"
    33 </telerik:RadToolTipManager> 

    Am I going at this the wrong way? Can you provide any help ?

    Thanks a lot,

    Dominic.
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 22 Apr 2009 Link to this post

    Hi dstj,

    The RadToolTip uses a lazy initialization and that is why its UI is created just before it is shown. This being said, in order to get the desired behavior, you should first call the show() method and set the content later as shown below:

     
            <script type="text/javascript">    
       Sys.Application.add_load(function() {    
          window.toolTipManager = $find("<%= RadToolTipManager1.ClientID %>");    
       });    
        
       function PopupTooltipManager(anchor)    
       {    
          if (!window.toolTipManager) {    
             return;    
           }    
                 
           //Find the tooltip for this element if it has been created    
           var tooltip = toolTipManager.getToolTipByElement(anchor);    
             
             
                 
           //Create a tooltip if no tooltip exists for such element    
           if (!tooltip) {    
              tooltip = toolTipManager.createToolTip(anchor);    
                  
                   //show the tooltip    
           tooltip.show();   
                  
              var contentElement = document.createElement('SPAN');      
              contentElement.innerHTML = 'Testing'    
              tooltip.set_contentElement(contentElement);    
           }    
         
           
        }    
            </script> 
     
            <div onclick="PopupTooltipManager(this);">  
                Create tooltip from manager</div> 
            <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server">  
            </telerik:RadToolTipManager> 


    Greetings,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top