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

What's _contentWrapper, why it's null, and how to initialize it?

3 Answers 50 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
أشرف
Top achievements
Rank 1
أشرف asked on 19 Dec 2013, 04:14 PM
Greetings,

Whenever I try to call the client side set_contentElement method of any tooltip object I get a null reference error because _contentWrapper is null. Here's the relevant excerpt from the RadControls code:
set_contentElement:function(contentElement){this._contentWrapper.innerHTML="";
It tries to set the innerHTML of _contentWrapper, but it's set to null, so the code breaks.

What's the role of _contentWrapper? And how to initialize it?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Dec 2013, 05:24 AM
Hi Ashraf,

Please have a look into the sample code snippet I tried and check this online demo and help documentation for further information about ContentElement in RadToolTip.

ASPX:
<asp:ListBox ID="lbSelectedLanguages" runat="server" Width="151px">
    <asp:ListItem Text="Click to select"></asp:ListItem>
</asp:ListBox>
<telerik:RadToolTip runat="server" ID="RadToolTip3" HideEvent="ManualClose" Position="MiddleRight"
    TargetControlID="lbSelectedLanguages">
    <asp:CheckBoxList ID="cblLanguages" runat="server">
        <asp:ListItem Text="English" Value="en"></asp:ListItem>
        <asp:ListItem Text="German" Value="de"></asp:ListItem>
        <asp:ListItem Text="French" Value="fr"></asp:ListItem>
    </asp:CheckBoxList>
    <asp:Button ID="Button1" runat="server" Text="Select" OnClientClick="InsertLanguages(); return false;">
    </asp:Button>
</telerik:RadToolTip>

JavaScript:
<script type="text/javascript">
    function InsertLanguages() {
        var tooltip = $find("<%=RadToolTip3.ClientID %>");
        //get the html element, holding the content of the tooltip
        var contentElement = tooltip.get_contentElement();
        alert(contentElement.innerHTML);
        //set a new html element to tooptip
        contentElement.innerHTML = "<span>demo</span>";
        alert(contentElement.innerHTML);
    }
</script>

Thanks,
Shinu.
0
أشرف
Top achievements
Rank 1
answered on 21 Dec 2013, 07:32 AM
Greetings and thanks for your reply,

The tooltip I have is created in the code not the markup. I created a custom control that displays itself in a tooltip.
I instantiate a tooltip and add a Literal control to its Controls collection.

I'm not on my office now, but when I was there, I tested with a RadTooltip created in the markup, that has a static DIV with some text in the content template, and still the problem occurred.

I think this should be filed as a bug, or otherwise Telerik should give instructions on how to instantiate this object.
0
أشرف
Top achievements
Rank 1
answered on 22 Dec 2013, 09:54 AM
With the setup you created, if I call set_contentElement the same problem occurs because _contentWrapper is null.

After some digging I found that this hack solves the problem:
var tooltip = $find("component id here");
 
    if(!tooltip.isCreated())
        tooltip._createUI(); // HACK:
 
    tooltip.set_contentElement(elem);

Again calling a private member, which I don't like. My code has a lot of _ members references.
I think _createUI should be public then.
Tags
ToolTip
Asked by
أشرف
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
أشرف
Top achievements
Rank 1
Share this question
or