diff options
-rw-r--r-- | docs/templates/pages/javascript.mustache | 8 | ||||
-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 |
5 files changed, 34 insertions, 1 deletions
diff --git a/docs/templates/pages/javascript.mustache b/docs/templates/pages/javascript.mustache index 0a3a7aa808..3e558c4f75 100644 --- a/docs/templates/pages/javascript.mustache +++ b/docs/templates/pages/javascript.mustache @@ -755,6 +755,9 @@ $('a[data-toggle="tab"]').on('shown', function (e) { <h4>.tooltip('toggle')</h4> <p>{{_i}}Toggles an element's tooltip.{{/i}}</p> <pre class="prettyprint linenums">$('#element').tooltip('toggle')</pre> + <h4>.tooltip('destroy')</h4> + <p>{{_i}}Destroys an element's tooltip.{{/i}}</p> + <pre class="prettyprint linenums">$('#element').tooltip('destroy')</pre> </section> @@ -821,7 +824,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) { <td>{{_i}}trigger{{/i}}</td> <td>{{_i}}string{{/i}}</td> <td>'hover'</td> - <td>{{_i}}how tooltip is triggered{{/i}} - hover | focus | manual</td> + <td>{{_i}}how popover is triggered{{/i}} - hover | focus | manual</td> </tr> <tr> <td>{{_i}}title{{/i}}</td> @@ -867,6 +870,9 @@ $('a[data-toggle="tab"]').on('shown', function (e) { <h4>.popover('toggle')</h4> <p>{{_i}}Toggles an elements popover.{{/i}}</p> <pre class="prettyprint linenums">$('#element').popover('toggle')</pre> + <h4>.popover('destroy')</h4> + <p>{{_i}}Destroys an element's popover.{{/i}}</p> + <pre class="prettyprint linenums">$('#element').popover('destroy')</pre> </section> 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') + }) + }) |