Skip to content
Permalink
Browse files

Added in support for global event triggering.

  • Loading branch information
jeresig committed Jul 6, 2006
1 parent b2d1558 commit 64179692a0eeadc7a6d93fe007bfc00990af6575
Showing with 23 additions and 3 deletions.
  1. +23 −3 jquery/jquery.js
@@ -812,9 +812,14 @@ jQuery.event = {
}
handlers[handler.guid] = handler;
element["on" + type] = jQuery.event.handle;

var g = jQuery.event.global;
if (!g[type]) g[type] = [];
g[type].push( element );
},

guid: 1,
global: {},

// Detach an event or set of events from an element
remove: function(element, type, handler) {
@@ -830,10 +835,25 @@ jQuery.event = {
jQuery.event.remove( element, j );
},

trigger: function(element,type,data) {
data = data || [ jQuery.event.fix({ type: type }) ];
if ( element && element["on" + type] )
trigger: function(type,data,element) {
// Touch up the incoming data
data = data || [];

// Handle triggering a single element
if ( element && element["on" + type] ) {
// Pass along a fake event
data.shift( jQuery.event.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] );
}
},

handle: function(event) {

0 comments on commit 6417969

Please sign in to comment.
You can’t perform that action at this time.