diff --git a/js/modal.js b/js/modal.js index 1a692e6af..0b392d161 100644 --- a/js/modal.js +++ b/js/modal.js @@ -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') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 2c610d83d..5755d2751 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -174,4 +174,23 @@ $(function () { }) .modal("show") }) + + test("should close reopened modal with [data-dismiss=modal] click", function () { + stop() + $.support.transition = false + var div = $("