Skip to content

Commit 0a3e034

Browse files
committed
Merge pull request twbs#5524 from martinstein/fix-tooltip-delegate-click
Fix tooltip not working in delegate events on click-trigger
2 parents 97bf02d + 6b017b9 commit 0a3e034

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

js/bootstrap-tooltip.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@
235235
this.enabled = !this.enabled
236236
}
237237

238-
, toggle: function () {
239-
this[this.tip().hasClass('in') ? 'hide' : 'show']()
238+
, toggle: function (e) {
239+
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
240+
self[self.tip().hasClass('in') ? 'hide' : 'show']()
240241
}
241242

242243
, destroy: function () {

js/tests/unit/bootstrap-tooltip.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,12 @@ $(function () {
142142
ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
143143
})
144144

145+
test("should show tooltip with delegate selector on click", function () {
146+
var div = $('<div><a href="#" rel="tooltip" title="Another tooltip"></a></div>')
147+
var tooltip = div.appendTo('#qunit-fixture')
148+
.tooltip({ selector: 'a[rel=tooltip]',
149+
trigger: 'click' })
150+
div.find('a').trigger('click')
151+
ok($(".tooltip").is('.fade.in'), 'tooltip is faded in')
152+
})
145153
})

0 commit comments

Comments
 (0)