}
// Make sure that the function being executed has a unique ID
- if ( !handler.guid )
+ if ( !handler.guid ) {
handler.guid = this.guid++;
+ // Don't forget to set guid for the original handler function
+ if (fn) fn.guid = handler.guid;
+ }
// Init the element's event structure
if (!element.$events)
if (element.addEventListener)
element.addEventListener(type, element.$handle, false);
else if (element.attachEvent)
- element.attachEvent("on" + type, element.$handle, false);
+ element.attachEvent("on" + type, element.$handle);
}
// Add the function to the element's handler list
if (element.removeEventListener)
element.removeEventListener(type, element.$handle, false);
else if (element.detachEvent)
- element.detachEvent("on" + type, element.$handle, false);
+ element.detachEvent("on" + type, element.$handle);
ret = null;
delete events[type];
}
*/
bind: function( type, data, fn ) {
return this.each(function(){
- jQuery.event.add( this, type, fn || data, data );
+ jQuery.event.add( this, type, fn || data, fn && data );
});
},
jQuery.event.add( this, type, function(event) {
jQuery(this).unbind(event);
return (fn || data).apply( this, arguments);
- }, data);
+ }, fn && data);
});
},