]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add event after template inserted 16147/head
authorJohann-S <johann.servoire@gmail.com>
Tue, 24 Mar 2015 19:47:35 +0000 (20:47 +0100)
committerJohann-S <johann.servoire@gmail.com>
Wed, 8 Apr 2015 11:10:53 +0000 (13:10 +0200)
docs/_includes/js/popovers.html
docs/_includes/js/tooltips.html
js/tests/unit/popover.js
js/tests/unit/tooltip.js
js/tooltip.js

index 5f3939987270ad8654a774428c88e90a58d6f689..dadddafc34da61caec24c5f5085afb8cf4443d88 100644 (file)
@@ -293,6 +293,10 @@ sagittis lacus vel augue laoreet rutrum faucibus.">
           <td>hidden.bs.popover</td>
           <td>This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).</td>
         </tr>
+        <tr>
+          <td>inserted.bs.popover</td>
+          <td>This event is fired after the <code>show.bs.popover</code> event when the popover template has been added to the DOM.</td>
+        </tr>
       </tbody>
     </table>
   </div><!-- /.table-responsive -->
index d606929ba8e880d902ded874e0363dac96931d0a..a8914b180eb79b133b18051095ce1acc1044275a 100644 (file)
@@ -260,6 +260,10 @@ $('#example').tooltip(options)
           <td>hidden.bs.tooltip</td>
           <td>This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).</td>
         </tr>
+        <tr>
+          <td>inserted.bs.tooltip</td>
+          <td>This event is fired after the <code>show.bs.tooltip</code> event when the tooltip template has been added to the DOM.</td>
+        </tr>
       </tbody>
     </table>
   </div><!-- /.table-responsive -->
index fbabab9e3e74135a7d7842782bbacaa0bb317967..2c3fd0cb046f3c08be322b8cb527fa54bbbf8928 100644 (file)
@@ -259,4 +259,21 @@ $(function () {
     assert.strictEqual($popover.data('bs.popover'), undefined, 'should not initialize the popover')
   })
 
+  QUnit.test('should fire inserted event', function (assert) {
+    assert.expect(2)
+    var done = assert.async()
+
+    $('<a href="#">@Johann-S</a>')
+      .appendTo('#qunit-fixture')
+      .on('inserted.bs.popover', function () {
+        assert.notEqual($('.popover').length, 0, 'popover was inserted')
+        assert.ok(true, 'inserted event fired')
+        done()
+      })
+      .bootstrapPopover({
+        title: 'Test',
+        content: 'Test'
+      })
+      .bootstrapPopover('show')
+  })
 })
index 57a59db1838239a16b658c47f175153427c3c7df..8086631c896fe7991a9d950a00b5fd484ca7e4bd 100644 (file)
@@ -139,6 +139,20 @@ $(function () {
       .bootstrapTooltip('show')
   })
 
+  QUnit.test('should fire inserted event', function (assert) {
+    assert.expect(2)
+    var done = assert.async()
+
+    $('<div title="tooltip title"/>')
+      .appendTo('#qunit-fixture')
+      .on('inserted.bs.tooltip', function () {
+        assert.notEqual($('.tooltip').length, 0, 'tooltip was inserted')
+        assert.ok(true, 'inserted event fired')
+        done()
+      })
+      .bootstrapTooltip('show')
+  })
+
   QUnit.test('should fire shown event', function (assert) {
     assert.expect(1)
     var done = assert.async()
index 27367880f7e636d2e74766043732a971813a59c9..6978e396b95e06428330134467773c915d525793 100644 (file)
         .data('bs.' + this.type, this)
 
       this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
+      this.$element.trigger('inserted.bs.' + this.type)
 
       var pos          = this.getPosition()
       var actualWidth  = $tip[0].offsetWidth