]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fixes #9362
authorfat <jacobthornton@gmail.com>
Sat, 17 Aug 2013 21:24:38 +0000 (14:24 -0700)
committerfat <jacobthornton@gmail.com>
Sat, 17 Aug 2013 21:24:38 +0000 (14:24 -0700)
js/modal.js
js/tests/unit/modal.js

index 1a692e6af17d8512a41bf86c526bed42402cc9fc..0b392d16155e2361aa8dd2fcabc5ad34f435a7fc 100644 (file)
@@ -25,7 +25,7 @@
 
   var Modal = function (element, options) {
     this.options   = options
-    this.$element  = $(element).on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+    this.$element  = $(element)
     this.$backdrop =
     this.isShown   = null
 
@@ -54,6 +54,8 @@
 
     this.escape()
 
+    this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+
     this.backdrop(function () {
       var transition = $.support.transition && that.$element.hasClass('fade')
 
index 2c610d83d9ac2dcd99dd4447f61275948c51b96a..5755d2751143d11f3321e00c9584543c1f59cbd4 100644 (file)
@@ -174,4 +174,23 @@ $(function () {
         })
         .modal("show")
     })
+
+    test("should close reopened modal with [data-dismiss=modal] click", function () {
+      stop()
+      $.support.transition = false
+      var div = $("<div id='modal-test'><div class='contents'><div id='close' data-dismiss='modal'></div></div></div>")
+      div
+        .bind("shown.bs.modal", function () {
+          $('#close').click()
+          ok(!$('#modal-test').is(":visible"), 'modal hidden')
+        })
+        .one("hidden.bs.modal", function() {
+          div.one('hidden.bs.modal', function () {
+            start()
+          }).modal("show")
+        })
+        .modal("show")
+
+      div.remove()
+    })
 })