Skip to main content

Bug Tracker

Side navigation

#5267 closed enhancement (fixed)

Opened September 18, 2009 06:02AM UTC

Closed June 25, 2010 02:53AM UTC

Submit Delegation Patch

Reported by: justinbmeyer Owned by: brandon
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: submit Cc: wycats@gmail.com
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)
  • eventsTest.patch (1.2 KB) - added by justinbmeyer September 19, 2009 11:56PM UTC.

    tests events, apply after previous

  • submit.patch (5.7 KB) - added by justinbmeyer September 18, 2009 06:03AM UTC.

    adds submit event delegation

Change History (6)

Changed September 18, 2009 09:58PM UTC by jdalton comment:1

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 September 20, 2009 12:12AM UTC by lrbabe comment:2

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

Changed September 20, 2009 12:15AM UTC by lrbabe comment:3

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.

Changed November 09, 2009 12:05PM UTC by john comment:4

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.

Changed February 02, 2010 09:54PM UTC by cz comment:5

Introduced new bug: http://dev.jquery.com/ticket/5833

Changed June 25, 2010 02:53AM UTC by dmethvin comment:6

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.