Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes tooltip('toggle') #6176

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@
}

, toggle: function (e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
self[self.tip().hasClass('in') ? 'hide' : 'show']()
var self = (e) ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this line to:

var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this

self.tip().hasClass('in') ? self.hide() : self.show()
}

, destroy: function () {
Expand Down
8 changes: 8 additions & 0 deletions js/tests/unit/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,12 @@ $(function () {
div.find('a').trigger('click')
ok($(".tooltip").is('.fade.in'), 'tooltip is faded in')
})

test("should show tooltip when toggle is called", function () {
var tooltip = $('<a href="#" rel="tooltip" title="tooltip on toggle"></a>')
.appendTo('#qunit-fixture')
.tooltip({trigger: 'manual'})
.tooltip('toggle')
ok($(".tooltip").is('.fade.in'), 'tooltip should be toggled in')
})
})