Bug Tracker

Opened 10 years ago

Closed 9 years ago

#5267 closed enhancement (fixed)

Submit Delegation Patch

Reported by: justinbmeyer Owned by: brandon
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: submit Cc: wycats@…
Blocked by: Blocking:

Description

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.

Suggestions:

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.

Attachments (2)

submit.patch (5.7 KB) - added by justinbmeyer 10 years ago.
adds submit event delegation
eventsTest.patch (1.2 KB) - added by justinbmeyer 10 years ago.
tests events, apply after previous

Download all attachments as: .zip

Change History (8)

Changed 10 years ago by justinbmeyer

Attachment: submit.patch added

adds submit event delegation

comment:1 Changed 10 years ago by jdalton

I wonder if posting auto includes me in the mailing list for this ticket... or if these tickets email the users. Here's to trying it out.

Changed 10 years ago by justinbmeyer

Attachment: eventsTest.patch added

tests events, apply after previous

comment:2 Changed 10 years ago by lrbabe

The second patch looks slightly complicated... What is this beforeFilter for, exaclty? I'm having the impression that the special event used to implement mouseenter and mouseleave does some kind of pre-filtering on the mouseover and mouseenter events without adding code everywhere in the event component.

I'm just concerned by the fact that if every special event requires to spread additional code throughout the component, soon no one will be able to understand how things work... Maybe it's just me, or it's the only way of doing it properly.

Regards, Louis-Rémi

comment:3 Changed 10 years ago by lrbabe

Oops, sorry, I thought I was in the original bug of Yehuda. I didn't took the time to read the whole description.

I share your concerns.

comment:4 Changed 10 years ago by john

Justin - could you toss these patches up in a Github fork? I'd like to be able to read through the changes and make comments.

comment:5 Changed 10 years ago by cz

comment:6 Changed 9 years ago by dmethvin

Resolution: fixed
Status: newclosed

I think this was added/fixed in 1.4 with full support for submit including event bubbling. Reopen if I'm wrong.

Note: See TracTickets for help on using tickets.