Skip to content

Commit

Permalink
on destroy, also hide. issue twbs#3880, pull twbs#4104
Browse files Browse the repository at this point in the history
  • Loading branch information
lookfirst committed Jul 20, 2012
1 parent 2ee9b27 commit 117f65d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/templates/pages/javascript.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<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>
<p>{{_i}}Hides and destroys an element's tooltip.{{/i}}</p>
<pre class="prettyprint linenums">$('#element').tooltip('destroy')</pre>
</section>

Expand Down Expand Up @@ -947,7 +947,7 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<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>
<p>{{_i}}Hides and destroys an element's popover.{{/i}}</p>
<pre class="prettyprint linenums">$('#element').popover('destroy')</pre>
</section>

Expand Down
1 change: 1 addition & 0 deletions js/bootstrap-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
}

, destroy: function () {
this.hide()
this.$element.off(this.options.ns).removeData('popover')
}

Expand Down
1 change: 1 addition & 0 deletions js/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
}

, destroy: function () {
this.hide()
this.$element.off(this.options.ns).removeData('tooltip')
}

Expand Down
2 changes: 2 additions & 0 deletions js/tests/unit/bootstrap-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ $(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').click[0].namespace == 'foo', 'popover still has click.foo')
ok(!popover.data('events').mouseover && !popover.data('events').mouseout, 'popover does not have any events')
Expand Down
2 changes: 2 additions & 0 deletions js/tests/unit/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ $(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').click[0].namespace == 'foo', 'tooltip still has click.foo')
ok(!tooltip.data('events').mouseover && !tooltip.data('events').mouseout, 'tooltip does not have any events')
Expand Down

0 comments on commit 117f65d

Please sign in to comment.