jQuery: The Write Less, Do More JavaScript Library

Changeset 5582

Show
Ignore:
Timestamp:
05/13/08 17:27:17 (3 months ago)
Author:
scott.gonzalez
Message:

UI Dialog: Fixed #2804: Delay event binding for overlays.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/ui.dialog.js

    r5484 r5582  
    310310            if (this.instances.length === 0) { 
    311311                // prevent use of anchors and inputs 
    312                 $('a, :input').bind(this.events, function() { 
    313                     // allow use of the element if inside a dialog and 
    314                     // - there are no modal dialogs 
    315                     // - there are modal dialogs, but we are in front of the topmost modal 
    316                     var allow = false; 
    317                     var $dialog = $(this).parents('.ui-dialog'); 
    318                     if ($dialog.length) { 
    319                         var $overlays = $('.ui-dialog-overlay'); 
    320                         if ($overlays.length) { 
    321                             var maxZ = parseInt($overlays.css('z-index'), 10); 
    322                             $overlays.each(function() { 
    323                                 maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10)); 
    324                             }); 
    325                             allow = parseInt($dialog.css('z-index'), 10) > maxZ; 
    326                         } else { 
    327                             allow = true; 
     312                // we use a setTimeout in case the overlay is created from an 
     313                // event that we're going to be cancelling (see #2804) 
     314                setTimeout(function() { 
     315                    $('a, :input').bind($.ui.dialog.overlay.events, function() { 
     316                        // allow use of the element if inside a dialog and 
     317                        // - there are no modal dialogs 
     318                        // - there are modal dialogs, but we are in front of the topmost modal 
     319                        var allow = false; 
     320                        var $dialog = $(this).parents('.ui-dialog'); 
     321                        if ($dialog.length) { 
     322                            var $overlays = $('.ui-dialog-overlay'); 
     323                            if ($overlays.length) { 
     324                                var maxZ = parseInt($overlays.css('z-index'), 10); 
     325                                $overlays.each(function() { 
     326                                    maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10)); 
     327                                }); 
     328                                allow = parseInt($dialog.css('z-index'), 10) > maxZ; 
     329                            } else { 
     330                                allow = true; 
     331                            } 
    328332                        } 
    329                     } 
    330                     return allow; 
    331                 }); 
     333                        return allow; 
     334                    }); 
     335                }, 1); 
    332336                 
    333337                // allow closing by pressing the escape key