Ticket #3662 (closed feature: fixed)
Add an Event class to jQuery
|Reported by:||flesler||Owned by:||flesler|
|Keywords:||Cc:||john, brandon, joern, davidserduke|
While it's possible to pass custom event objects to jQuery.trigger, it's pretty complicated and lengthy to do that.
Also, there's no way to add custom attributes to the event objects when triggering (binding data is the closest).
In addition, this class could be used by both jQuery.event.fix and jQuery.trigger. Instead of creating literal objects with empty or custom methods (preventDefault,etc) we could have those in a prototype. That's much lighter than thousands of lambda functions.
This change breaks 2 old behaviors (on purpose).
- It's not possible to pass an event object in the data array. It has to be passed as first argument, instead of the type, its 'type' will be used.
- extra functions passed to jQuery.trigger won't get the event object (they used to get it if it was on the data array).
These are the new behaviors allowed:
$('#foo').trigger( new jQuery.Event('click') );
var e = new jQuery.Event('foo'); e.customAttr = 'bar'; $('#foo').trigger( e );
- need changed from Patch to Commit
- Status changed from new to assigned
- Status changed from assigned to closed
- Resolution set to fixed