mirror of
https://github.com/Hopiu/bootstrap.git
synced 2026-03-26 17:20:29 +00:00
Merge pull request #5524 from martinstein/fix-tooltip-delegate-click
Fix tooltip not working in delegate events on click-trigger
This commit is contained in:
commit
0a3e034891
2 changed files with 11 additions and 2 deletions
5
js/bootstrap-tooltip.js
vendored
5
js/bootstrap-tooltip.js
vendored
|
|
@ -235,8 +235,9 @@
|
|||
this.enabled = !this.enabled
|
||||
}
|
||||
|
||||
, toggle: function () {
|
||||
this[this.tip().hasClass('in') ? 'hide' : 'show']()
|
||||
, toggle: function (e) {
|
||||
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
|
||||
self[self.tip().hasClass('in') ? 'hide' : 'show']()
|
||||
}
|
||||
|
||||
, destroy: function () {
|
||||
|
|
|
|||
8
js/tests/unit/bootstrap-tooltip.js
vendored
8
js/tests/unit/bootstrap-tooltip.js
vendored
|
|
@ -142,4 +142,12 @@ $(function () {
|
|||
ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
|
||||
})
|
||||
|
||||
test("should show tooltip with delegate selector on click", function () {
|
||||
var div = $('<div><a href="#" rel="tooltip" title="Another tooltip"></a></div>')
|
||||
var tooltip = div.appendTo('#qunit-fixture')
|
||||
.tooltip({ selector: 'a[rel=tooltip]',
|
||||
trigger: 'click' })
|
||||
div.find('a').trigger('click')
|
||||
ok($(".tooltip").is('.fade.in'), 'tooltip is faded in')
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue