Skip to content

Commit c6b62f0

Browse files
committed
Merge pull request twbs#16147 from Johann-S/event_inserted
Fixes twbs#16124.
2 parents 7993251 + 3d71eae commit c6b62f0

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

docs/_includes/js/popovers.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ <h3 id="popovers-events">Events</h3>
293293
<td>hidden.bs.popover</td>
294294
<td>This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).</td>
295295
</tr>
296+
<tr>
297+
<td>inserted.bs.popover</td>
298+
<td>This event is fired after the <code>show.bs.popover</code> event when the popover template has been added to the DOM.</td>
299+
</tr>
296300
</tbody>
297301
</table>
298302
</div><!-- /.table-responsive -->

docs/_includes/js/tooltips.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ <h3 id="tooltips-events">Events</h3>
260260
<td>hidden.bs.tooltip</td>
261261
<td>This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).</td>
262262
</tr>
263+
<tr>
264+
<td>inserted.bs.tooltip</td>
265+
<td>This event is fired after the <code>show.bs.tooltip</code> event when the tooltip template has been added to the DOM.</td>
266+
</tr>
263267
</tbody>
264268
</table>
265269
</div><!-- /.table-responsive -->

js/tests/unit/popover.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,21 @@ $(function () {
259259
assert.strictEqual($popover.data('bs.popover'), undefined, 'should not initialize the popover')
260260
})
261261

262+
QUnit.test('should fire inserted event', function (assert) {
263+
assert.expect(2)
264+
var done = assert.async()
265+
266+
$('<a href="#">@Johann-S</a>')
267+
.appendTo('#qunit-fixture')
268+
.on('inserted.bs.popover', function () {
269+
assert.notEqual($('.popover').length, 0, 'popover was inserted')
270+
assert.ok(true, 'inserted event fired')
271+
done()
272+
})
273+
.bootstrapPopover({
274+
title: 'Test',
275+
content: 'Test'
276+
})
277+
.bootstrapPopover('show')
278+
})
262279
})

js/tests/unit/tooltip.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ $(function () {
139139
.bootstrapTooltip('show')
140140
})
141141

142+
QUnit.test('should fire inserted event', function (assert) {
143+
assert.expect(2)
144+
var done = assert.async()
145+
146+
$('<div title="tooltip title"/>')
147+
.appendTo('#qunit-fixture')
148+
.on('inserted.bs.tooltip', function () {
149+
assert.notEqual($('.tooltip').length, 0, 'tooltip was inserted')
150+
assert.ok(true, 'inserted event fired')
151+
done()
152+
})
153+
.bootstrapTooltip('show')
154+
})
155+
142156
QUnit.test('should fire shown event', function (assert) {
143157
assert.expect(1)
144158
var done = assert.async()

js/tooltip.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
.data('bs.' + this.type, this)
186186

187187
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
188+
this.$element.trigger('inserted.bs.' + this.type)
188189

189190
var pos = this.getPosition()
190191
var actualWidth = $tip[0].offsetWidth

0 commit comments

Comments
 (0)