diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index a08952a4cfdc..34e3892686d2 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -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 + self.tip().hasClass('in') ? self.hide() : self.show() } , destroy: function () { diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index ba51347433ff..a227b4c9ce53 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -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 = $('') + .appendTo('#qunit-fixture') + .tooltip({trigger: 'manual'}) + .tooltip('toggle') + ok($(".tooltip").is('.fade.in'), 'tooltip should be toggled in') + }) }) \ No newline at end of file