diff options
author | ♒∆✝ <jacobthornton@gmail.com> | 2012-07-23 01:40:09 +0400 |
---|---|---|
committer | ♒∆✝ <jacobthornton@gmail.com> | 2012-07-23 01:40:09 +0400 |
commit | 48fc0ad56953f260b0f926f0fd7564e75cd9e9f9 (patch) | |
tree | ff8aa6bded07f4cf58633213e6eb7192f07d9920 /js | |
parent | e9f374f04175820d254cfbcf619908e6ac1493ed (diff) | |
parent | d76c8991424b91050636fb94e740daa123306e95 (diff) |
Merge pull request #4104 from lookfirst/2.1.0-wip-fix-destroy
namespace the events for popover/tooltip
Diffstat (limited to 'js')
-rw-r--r-- | js/bootstrap-popover.js | 2 | ||||
-rw-r--r-- | js/bootstrap-tooltip.js | 8 | ||||
-rw-r--r-- | js/tests/unit/bootstrap-popover.js | 8 | ||||
-rw-r--r-- | js/tests/unit/bootstrap-tooltip.js | 8 |
4 files changed, 18 insertions, 8 deletions
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index fe22ecb47c..2e6d9c32a5 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -72,7 +72,7 @@ } , destroy: function () { - this.$element.off().removeData('popover') + this.hide().$element.off('.' + this.type).removeData(this.type) } }) diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index f280e36966..f9447410ec 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -47,8 +47,8 @@ if (this.options.trigger != 'manual') { eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur' - this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this)) - this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this)) + this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) + this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) } this.options.selector ? @@ -176,6 +176,8 @@ $.support.transition && this.$tip.hasClass('fade') ? removeWithAnimation() : $tip.remove() + + return this } , fixTitle: function () { @@ -236,7 +238,7 @@ } , destroy: function () { - this.$element.off().removeData('tooltip') + this.hide().$element.off('.' + this.type).removeData(this.type) } } diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js index 6d5d9f7a18..daffe215c9 100644 --- a/js/tests/unit/bootstrap-popover.js +++ b/js/tests/unit/bootstrap-popover.js @@ -92,12 +92,16 @@ $(function () { }) test("should destroy popover", function () { - var popover = $('<div/>').popover() + var popover = $('<div/>').popover().on('click.foo', function(){}) ok(popover.data('popover'), 'popover has data') ok(popover.data('events').mouseover && popover.data('events').mouseout, 'popover has hover event') + ok(popover.data('events').click[0].namespace == 'foo', 'popover has extra click.foo event') + popover.popover('show') popover.popover('destroy') + ok(!popover.hasClass('in'), 'popover is hidden') ok(!popover.data('popover'), 'popover does not have data') - ok(!popover.data('events'), 'popover does not have any events') + ok(popover.data('events').click[0].namespace == 'foo', 'popover still has click.foo') + ok(!popover.data('events').mouseover && !popover.data('events').mouseout, 'popover does not have any events') }) })
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 7852305c1e..2eb8c8f7c9 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -129,12 +129,16 @@ $(function () { }) test("should destroy tooltip", function () { - var tooltip = $('<div/>').tooltip() + var tooltip = $('<div/>').tooltip().on('click.foo', function(){}) ok(tooltip.data('tooltip'), 'tooltip has data') ok(tooltip.data('events').mouseover && tooltip.data('events').mouseout, 'tooltip has hover event') + ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip has extra click.foo event') + tooltip.tooltip('show') tooltip.tooltip('destroy') + ok(!tooltip.hasClass('in'), 'tooltip is hidden') ok(!tooltip.data('tooltip'), 'tooltip does not have data') - ok(!tooltip.data('events'), 'tooltip does not have any events') + ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip still has click.foo') + ok(!tooltip.data('events').mouseover && !tooltip.data('events').mouseout, 'tooltip does not have any events') }) }) |