diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/bootstrap-popover.js | 4 | ||||
-rw-r--r-- | js/bootstrap-tooltip.js | 4 | ||||
-rw-r--r-- | js/tests/unit/bootstrap-popover.js | 10 | ||||
-rw-r--r-- | js/tests/unit/bootstrap-tooltip.js | 9 |
4 files changed, 27 insertions, 0 deletions
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index c6c1f8b473..fe22ecb47c 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -71,6 +71,10 @@ return this.$tip } + , destroy: function () { + this.$element.off().removeData('popover') + } + }) diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index f5f9fad3f4..f280e36966 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -235,6 +235,10 @@ this[this.tip().hasClass('in') ? 'hide' : 'show']() } + , destroy: function () { + this.$element.off().removeData('tooltip') + } + } diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js index afd6b170b4..6d5d9f7a18 100644 --- a/js/tests/unit/bootstrap-popover.js +++ b/js/tests/unit/bootstrap-popover.js @@ -90,4 +90,14 @@ $(function () { ok(!$('.popover').length, 'popover was removed') $('#qunit-fixture').empty() }) + + test("should destroy popover", function () { + var popover = $('<div/>').popover() + ok(popover.data('popover'), 'popover has data') + ok(popover.data('events').mouseover && popover.data('events').mouseout, 'popover has hover event') + popover.popover('destroy') + ok(!popover.data('popover'), 'popover does not have data') + ok(!popover.data('events'), '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 51e03486e6..7852305c1e 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -128,4 +128,13 @@ $(function () { }, 200) }) + test("should destroy tooltip", function () { + var tooltip = $('<div/>').tooltip() + ok(tooltip.data('tooltip'), 'tooltip has data') + ok(tooltip.data('events').mouseover && tooltip.data('events').mouseout, 'tooltip has hover event') + tooltip.tooltip('destroy') + ok(!tooltip.data('tooltip'), 'tooltip does not have data') + ok(!tooltip.data('events'), 'tooltip does not have any events') + }) + }) |