Made it so that the last return value is always returned from handle() (unless one...
[jquery.git] / src / event / event.js
index 2d00711..7f0ec64 100644 (file)
@@ -170,10 +170,14 @@ jQuery.event = {
                        args[0].handler = c[j];
                        args[0].data = c[j].data;
 
-                       if ( c[j].apply( this, args ) === false ) {
+                       var tmp = c[j].apply( this, args );
+
+                       if ( val !== false )
+                               val = tmp;
+
+                       if ( tmp === false ) {
                                event.preventDefault();
                                event.stopPropagation();
-                               val = false;
                        }
                }
 
@@ -529,6 +533,9 @@ jQuery.fn.extend({
         * @see $(Function)
         */
        ready: function(f) {
+               // Attach the listeners
+               bindReady();
+
                // If the DOM is already ready
                if ( jQuery.isReady )
                        // Execute the function immediately
@@ -928,7 +935,13 @@ jQuery.extend({
                };
                        
        });
-       
+
+var readyBound = false;
+
+function bindReady(){
+       if ( readyBound ) return;
+       readyBound = true;
+
        // If Mozilla is used
        if ( jQuery.browser.mozilla || jQuery.browser.opera )
                // Use the handy event callback
@@ -974,3 +987,4 @@ jQuery.extend({
 
        // A fallback to window.onload, that will always work
        jQuery.event.add( window, "load", jQuery.ready );
+}