Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#10352 closed feature (wontfix)

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/

Change History (5)

comment:1 Changed 3 years ago by Scott González

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.

comment:2 Changed 3 years ago by 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.

comment:3 in reply to:  2 Changed 3 years ago by tj.vantoll

Replying to 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?

comment:4 Changed 3 years ago by Scott González

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.

comment:5 in reply to:  4 Changed 3 years ago by tj.vantoll

Replying to 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.

Note: See TracTickets for help on using tickets.