]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Don't bind overlay event handlers if the overlays are destroyed before the...
authorScott González <scott.gonzalez@gmail.com>
Sat, 28 Mar 2009 16:33:59 +0000 (16:33 +0000)
committerScott González <scott.gonzalez@gmail.com>
Sat, 28 Mar 2009 16:33:59 +0000 (16:33 +0000)
ui/ui.dialog.js

index 553a6748dead8e283d83d29236adb24bad27abee..cbd0b107c6a4835261530cd383642396c1d7b8f6 100644 (file)
@@ -533,10 +533,13 @@ $.extend($.ui.dialog.overlay, {
                        // we use a setTimeout in case the overlay is created from an
                        // event that we're going to be cancelling (see #2804)
                        setTimeout(function() {
-                               $(document).bind($.ui.dialog.overlay.events, function(event) {
-                                       var dialogZ = $(event.target).parents('.ui-dialog').css('zIndex') || 0;
-                                       return (dialogZ > $.ui.dialog.overlay.maxZ);
-                               });
+                               // handle $(el).dialog().dialog('close') (see #4065)
+                               if ($.ui.dialog.overlay.instances.length) {
+                                       $(document).bind($.ui.dialog.overlay.events, function(event) {
+                                               var dialogZ = $(event.target).parents('.ui-dialog').css('zIndex') || 0;
+                                               return (dialogZ > $.ui.dialog.overlay.maxZ);
+                                       });
+                               }
                        }, 1);
 
                        // allow closing by pressing the escape key