Skip to main content

Search and Top Navigation

#10352 closed feature (wontfix)

Opened July 23, 2014 08:26PM UTC

Closed July 23, 2014 10:15PM UTC

Last modified July 24, 2014 02:22PM UTC

Allow to selectively enable/disable tooltips on children elements.

Reported by: Retronator Owned by:
Priority: minor Milestone: none
Component: ui.tooltip Version: 1.11.0
Keywords: Cc:
Blocked by: Blocking:
Description

When you enable tooltips using the document:

$( document ).tooltip();

I would like to then be able to disable the tooltip on only a specific DOM element inside document.

For example, I have a

<button id='my-button' title='Tooltip text'>Click me</button>

and on click I would like to disable the tooltip on just that button:

$('#my-button').click(function() {
   $('#my-button').tooltip('disable');
});

Is there already a way to do this? If I understand correctly, you can only send enable/disable/remove commands to the original DOM element for which you enabled tooltip on.

Here is a JSFiddle with a test case: http://jsfiddle.net/degFa/

And here is my current workaround: http://jsfiddle.net/degFa/2/

Attachments (0)
Change History (5)

Changed July 23, 2014 10:15PM UTC by scottgonzalez comment:1

resolution: → wontfix
status: newclosed

Either manage this yourself via the items option or don't use delegation. I think adding this would complicate the plugin too much.

Changed July 24, 2014 12:06AM UTC by Retronator comment:2

If you look at my current workaround, I am handling this exactly with the items option, but the problem is, this is not reactive. When I remove the class I use with items to selectively enable tooltips, the current displayed tooltip doesn't automatically disappear. That's why I have the extra hack of finding the DOM element jQuery UI created and manually removing it.

The other alternative you suggest, when you don't use delegation, it works, but again not reactively for things that are later added. So it's not really a very elegant option, especially for dynamic web frameworks like Meteor.

Changed July 24, 2014 12:49PM UTC by tj.vantoll comment:3

Replying to [comment:2 Retronator]:

If you look at my current workaround, I am handling this exactly with the items option, but the problem is, this is not reactive. When I remove the class I use with items to selectively enable tooltips, the current displayed tooltip doesn't automatically disappear. That's why I have the extra hack of finding the DOM element jQuery UI created and manually removing it. The other alternative you suggest, when you don't use delegation, it works, but again not reactively for things that are later added. So it's not really a very elegant option, especially for dynamic web frameworks like Meteor.

Something like this should work for you for now: http://jsfiddle.net/tj_vantoll/degFa/3/.

When I remove the class I use with items to selectively enable tooltips, the current displayed tooltip doesn't automatically disappear.

This is expected, as we don't listen for attribute changes. However, you bring up a good point: right now there doesn't appear to be a way to close a delegated tooltip. The

close()
method is documented to only work on non-delegated tooltips, so the only thing I can come up with is
$( ".ui-tooltip" ).hide()
. Scott is there something else I'm not thinking of?

Changed July 24, 2014 02:15PM UTC by scottgonzalez comment:4

We could make close() accept a target element. But that's about as far as I'd like to go; I really don't want to get into tracking individually disabled tooltips in the delegated scenario.

Changed July 24, 2014 02:22PM UTC by tj.vantoll comment:5

Replying to [comment:4 scott.gonzalez]:

We could make close() accept a target element. But that's about as far as I'd like to go; I really don't want to get into tracking individually disabled tooltips in the delegated scenario.

I definitely don't want to track individually disabled tooltips. I like changing close(), but I think we should hold off, as I don't believe this has come up in the handful of years the tooltip widget has been around. Users should write an extension that works that way for now. If others want this behavior in the core widget they can comment here.