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

Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
Mark W
  • 5,824
  • 15
  • 59
  • 97

2 Answers2

38

A bit shorter way:

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

lxgreen
  • 1,511
  • 15
  • 14
  • 14
    +1 this worked for what I needed, the opposite, wanted them on mouse only, not focus: $(element).tooltip().off("focusin focusout"); – eselk Apr 01 '13 at 21:53
  • 1
    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. – RaphaelDDL Oct 03 '14 at 18:28
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/

Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307