How to make jQueryUI tooltip apply only on focus
Asked Answered
E

2

26

How can I make the new JqueryUI tooltip visible only on focus: At the moment its on focus and on hover. I believe this is since JqueryUI 1.9

Exposure answered 5/11, 2012 at 13:40 Comment(1)
Wow such a simple question but I don't see a simple answer :(Wideman
P
38

A bit shorter way:

$(".selector").tooltip().off("mouseover mouseout");

Proprietor answered 21/2, 2013 at 8:30 Comment(2)
+1 this worked for what I needed, the opposite, wanted them on mouse only, not focus: $(element).tooltip().off("focusin focusout");Disapprobation
An add-on to the answer: .off("mouseover mouseout"); will off all mouse over/out events. If you are using them, they will be unbind too. To make sure you are just doing off on the tooltip's ones, do like this: $(".selector").tooltip(); var tooltipInstanceNamespace = $(".selector").tooltip("instance").eventNamespace; $(".selector").off('mouseover'+tooltipInstanceNamespace' mouseout'+tooltipInstanceNamespace); This will off only the listeners with that tooltip instance namespace.Nog
W
15

This isn't ideal, but it should work:

$(".selector").tooltip({
    disabled: true
}).on("focusin", function () {
    $(this)
        .tooltip("enable")
        .tooltip("open");
}).on("focusout", function () {
    $(this)
        .tooltip("close")
        .tooltip("disable");
});

Basically, enable/open the tooltip on focusin and disable/close on focusout.

Example: http://jsfiddle.net/WmRuN/

Wideman answered 5/11, 2012 at 19:17 Comment(2)
I suspected something like this would be needed. Thanks.Exposure
Also. One problem I didn't think about with this, is that the browser inserts the standard titles on hover. :(Exposure

© 2022 - 2024 — McMap. All rights reserved.