diff --git a/jquery.modal.js b/jquery.modal.js index 1c20e5a..21c6424 100644 --- a/jquery.modal.js +++ b/jquery.modal.js @@ -69,9 +69,9 @@ }, close: function() { + $(document).off('keydown.modal'); this.unblock(); this.hide(); - $(document).off('keydown.modal'); }, block: function() { @@ -166,9 +166,10 @@ $.modal.close = function(event) { if (!current) return; if (event) event.preventDefault(); - current.close(); var that = current.$elm; - current = null; + current.close(); + if (that.is(current.$elm)) + current = null; return that; };