This is a migrated thread and some comments may be shown as answers.

Client-side: set content to DOM element.

1 Answer 216 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
dstj
Top achievements
Rank 1
dstj asked on 20 Apr 2009, 07:29 PM
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 :

<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); 
          
         var contentElement = document.createElement('SPAN');   
         contentElement.innerHTML = 'Testing' 
         tooltip.set_contentElement(contentElement); 
      } 
 
      //show the tooltip 
      tooltip.show(); 
   } 
</script> 
 
 
<div onclick="PopupTooltipManager(this);">Create tooltip from manager</div> 
 
<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"
</telerik:RadToolTipManager> 

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

Thanks a lot,

Dominic.

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 22 Apr 2009, 10:48 AM
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.
Tags
ToolTip
Asked by
dstj
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or