Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Tooltips on Hover & Focus

Twitter bootstrap tooltip trigger default is hover.

I can add data-trigger="focus" to cause the tooltip to display on focus, but how I do both hover and focus?

like image 255
RLeisinger Avatar asked Nov 26 '12 20:11

RLeisinger


3 Answers

trigger is a single-value property, so you have to fake either of both methods:

$('.tooltip').tooltip({trigger: 'hover'}).each(function () {
  var $this = $(this), data = $this.data('tooltip');
  $this.on('focus.tooltip', $.proxy(data.enter, data))
    .on('blur.tooltip', $.proxy(data.leave, data));
});

Update: Alternatively, you can use my patch to Twitter Bootstrap to make trigger a multi-value property and just set it to hover focus.

like image 169
Adrian Heine Avatar answered Oct 20 '22 05:10

Adrian Heine


have you tried data-trigger="focus hover"

like image 21
bluetoft Avatar answered Oct 20 '22 05:10

bluetoft


solution by @Adrian does not work on Bootstrap 3. Use following:

$('[rel=tooltip]').tooltip();
$(document).on('hover', '[rel=tooltip]', function () { $(this).tooltip('show'); });
$(document).on('focus', '[rel=tooltip]', function () { $(this).tooltip('show'); });
like image 23
Dmitry Efimenko Avatar answered Oct 20 '22 05:10

Dmitry Efimenko