Fixed the issue where $("body").find("div#foo") would ignore the specified tag name...
[jquery.git] / src / event / event.js
index 59fff51..a4a99d9 100644 (file)
@@ -130,7 +130,7 @@ jQuery.event = {
                if ( !element ) {
                        // Only trigger if we've ever bound an event for it
                        if ( this.global[type] )
-                               jQuery("*").trigger(type, data);
+                               jQuery("*").add([window, document]).trigger(type, data);
 
                // Handle triggering a single element
                } else {
@@ -161,7 +161,7 @@ jQuery.event = {
                // Empty object is for triggered events with no data
                event = jQuery.event.fix( event || window.event || {} ); 
 
-               var c = this.$events && this.$events[event.type], args = [].slice.call( arguments, 1 );
+               var c = this.$events && this.$events[event.type], args = Array.prototype.slice.call( arguments, 1 );
                args.unshift( event );
 
                for ( var j in c ) {
@@ -529,6 +529,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
@@ -578,8 +581,6 @@ jQuery.extend({
        }
 });
 
-new function(){
-
        /**
         * Bind a function to the scroll event of each matched element.
         *
@@ -930,7 +931,13 @@ new function(){
                };
                        
        });
-       
+
+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
@@ -976,5 +983,4 @@ new function(){
 
        // A fallback to window.onload, that will always work
        jQuery.event.add( window, "load", jQuery.ready );
-       
-};
+}