From f40cc2b8be2fc4978f726a98212f336c16e32347 Mon Sep 17 00:00:00 2001 From: xfra35 Date: Fri, 28 Aug 2015 17:41:59 +0200 Subject: [PATCH] Smart close: check if we're destroying the right instance --- jquery.modal.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; };