From 0a9c5698398f7a8347d2d5956c9d11a3eb2933d6 Mon Sep 17 00:00:00 2001 From: John Resig Date: Thu, 6 Jul 2006 14:50:56 +0000 Subject: [PATCH] Bug fix with how global event triggers are handled. --- jquery/jquery.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/jquery/jquery.js b/jquery/jquery.js index bd2f92fae..352b849ad 100644 --- a/jquery/jquery.js +++ b/jquery/jquery.js @@ -811,11 +811,11 @@ jQuery.event = { handlers[0] = element["on" + type]; } handlers[handler.guid] = handler; - element["on" + type] = jQuery.event.handle; + element["on" + type] = this.handle; - var g = jQuery.event.global; - if (!g[type]) g[type] = []; - g[type].push( element ); + if (!this.global[type]) + this.global[type] = []; + this.global[type].push( element ); }, guid: 1, @@ -832,27 +832,27 @@ jQuery.event = { delete element.events[type][i]; else for ( var j in element.events ) - jQuery.event.remove( element, j ); + this.remove( element, j ); }, trigger: function(type,data,element) { // Touch up the incoming data data = data || []; + // Handle a global trigger + if ( !element ) { + var g = this.global[type]; + if ( g ) + for ( var i = 0; i < g.length; i++ ) + this.trigger( type, data, g[i] ); + // Handle triggering a single element - if ( element && element["on" + type] ) { + } else if ( element["on" + type] ) { // Pass along a fake event - data.shift( jQuery.event.fix({ type: type, target: element }) ); + data.unshift( this.fix({ type: type, target: element }) ); // Trigger the event element["on" + type].apply( element, data ); - - // Handle a global trigger - } else if ( !element ) { - var g = jQuery.event.global[type]; - if ( g ) - for ( var i = 0; i < g.length; i++ ) - jQuery.event.trigger( type, data, g[i] ); } },