- // Fix for custom events
- event.currentTarget = elem;
-
- data.unshift( event );
-
- var fn = jQuery.isFunction( elem[ type ] );
-
- // Trigger the event, it is assumed that "handle" is a function
- var handle = jQuery.data(elem, "handle");
- if ( handle )
- handle.apply( elem, data );
-
- // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
- if ( (!fn || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
- event.result = false;
-
- // Extra functions don't get the custom event object
- data.shift();
-
- // Handle triggering of extra function
- if ( extra && jQuery.isFunction( extra ) ) {
- // call the extra function and tack the current return value on the end for possible inspection
- var ret = extra.apply( elem, event.result == null ? data : data.concat( event.result ) );
- // if anything is returned, give it precedence and have it overwrite the previous value
- if ( ret !== undefined )
- event.result = ret;
- }