Ticket #5267 (closed enhancement: fixed)
Submit Delegation Patch
|Reported by:||justinbmeyer||Owned by:||brandon|
submit delegation patch
This improves on the existing functionality in 2 ways:
It adds jQuery.support.submitBubbles and only uses that event
It can handle multiple events delegated on the document and delete them.
Some issues: Instead of making submit special, I am added a special object to jQuery.event.special.live.
I wanted to have a check if the special exists, but as jQuery.support happens after events, I have to do the check in the live function. Maybe support will get split up and I can make this look nicer.
How it works:
It basically adds a keypress and click delegated event, but alls adds to $.data('events').live a name:value pair to keep track of which elements are delegated. It also uses an altLive property on the proxy function so when keypress happens, the 'submit' live event can respond to events in altLive.
This is only to get something working. I'll submit a patch for testing.
The core difficulty is everything is that data is put on the event handler function. And as all delegated events share the same event handler (liveHandler) this makes it hard to distinguish between different events and even harder to have something like submit know to remove keypress and click.
I think trying to have DOM events, custom events, and event delegation use the same code is making the code a little unwieldy. The double event.add that happens in event delegation is the best example of this. I think the code could be made much simpler by having delegation manage the list of events apart from event.add. This would perform faster as you can quickly get to only the events that match your event.type.
This breaks how events are stored, but delegation is a different animal.