Skip to content

Commit

Permalink
Merge pull request twbs#6378 from Yohn/patch-7
Browse files Browse the repository at this point in the history
fixes tooltip insert problems
  • Loading branch information
fat committed Dec 25, 2012
2 parents 90cdef8 + 340d901 commit b9c7f29
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,14 @@ <h3>Options</h3>
<p>Object structure is: <code>delay: { show: 500, hide: 100 }</code></p>
</td>
</tr>
<tr>
<td>container</td>
<td>string | false</td>
<td>false</td>
<td>
<p>Appends the tooltip to a specific element <code>container: 'body'</code></p>
</td>
</tr>
</tbody>
</table>
<div class="alert alert-info">
Expand Down
8 changes: 8 additions & 0 deletions docs/templates/pages/javascript.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,14 @@ $('a[data-toggle="tab"]').on('shown', function (e) {
<p>{{_i}}Object structure is: <code>delay: { show: 500, hide: 100 }</code>{{/i}}</p>
</td>
</tr>
<tr>
<td>{{_i}}container{{/i}}</td>
<td>{{_i}}string | false{{/i}}</td>
<td>{{_i}}false{{/i}}</td>
<td>
<p>{{_i}}Appends the tooltip to a specific element <code>container: 'body'</code>{{/i}}</p>
</td>
</tr>
</tbody>
</table>
<div class="alert alert-info">
Expand Down
4 changes: 3 additions & 1 deletion js/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
$tip
.detach()
.css({ top: 0, left: 0, display: 'block' })
.insertAfter(this.$element)

this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)

pos = this.getPosition()

Expand Down Expand Up @@ -290,6 +291,7 @@
, title: ''
, delay: 0
, html: false
, container: false
}


Expand Down
10 changes: 10 additions & 0 deletions js/tests/unit/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,14 @@ $(function () {
.tooltip('toggle')
ok($(".tooltip").is('.fade.in'), 'tooltip should be toggled in')
})

test("should place tooltips inside the body", function () {
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
.appendTo('#qunit-fixture')
.tooltip({container:'body'})
.tooltip('show')
ok($("body > .tooltip").length, 'inside the body')
ok(!$("#qunit-fixture > .tooltip").length, 'not found in parent')
tooltip.tooltip('hide')
})
})

0 comments on commit b9c7f29

Please sign in to comment.