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

JavaScript click and hover on tooltip.

4 Answers 94 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 15 Aug 2011, 05:23 PM
I have been trying to figure out a solution I can use across my entire site. Each tooltip has different content and they all have a targetControlId set on them. My problem is, on load, I want to find all tooltips on the page without referencing specific name. Once I have the collection I need to be able to access the targetControlId so I can bind hover AND click events through JavaScript. I have the code for assigning hover and click, I just need the collection and access to the targetControlId attribute.

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 17 Aug 2011, 08:25 AM
Hello Patrick,

  If you set the ShowEvent of the RadToolTip to a value, different than FromCode it will register the appropriate event itself, so it should not be necessary that you do this by hand, as showing the tooltip OnMouseOver will precede the click in any case, so if the HideEvent is set to ManualClose or FromCode a subsequent click on the target element will not hide the tooltip.

  Nevertheless you can simply declare the IDs of the tooltips with subsequent numbers and use a simple loop to $find() them. You can also output the ClientID values in a hidden field in the Page_Load server-side event, for example, separated with a character (for example "|") and by using the split() JavaScript method get them and again use a loop.

If you have a multitude of controls to tooltipify I would also recommend examining the RadToolTipManager control, as it could decrease the amount of markup and code you will need. It also provides Load-on-demand functionality which will speed up the initial page load.


Regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Patrick
Top achievements
Rank 1
answered on 17 Aug 2011, 03:22 PM
Your first recommendation wont work for me because I have a javascript function that body click handler to the tooltips so they close if someone clicks outside the tooltip.  So unless there is a way to have it close when someone clicks outside the tooltip, I can't use the hover showevent.

The second solution doesn't work either because some pages wont have tooltips, others may have ten, it's all pretty random.  I'm looking for a solution for all pages.
0
Accepted
Marin Bratanov
Telerik team
answered on 19 Aug 2011, 02:35 PM
Hi Patrick,

I think I may have a suggestion that will allow you to access the controls. You would first get a reference to all the RadControls on the page and if they have the targetControlID property then they are RadToolTips. You can then access it and use it as you like:
function pageLoad()
{
    var theRadControls = $telerik.radControls;
    for (var i = 0; i < theRadControls.length; i++)
    {
        if (theRadControls[i]._targetControlID)
        {
            alert(theRadControls[i].get_targetControlID());
        }
    }
}

The $telerik.radControls array is an object we provide in our static client library. Feel free to further modify this code to match your custom scenario.

I hope my reply was helpful.

Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Patrick
Top achievements
Rank 1
answered on 19 Aug 2011, 03:40 PM
That is exactly what I was looking for.  I figured it out yesterday afternoon but nevertheless, it's exactly what I needed.  I hope this helps someone else in the future.
Tags
ToolTip
Asked by
Patrick
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or