Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#6903 closed enhancement (fixed)

special events need a way to determine whether they are being bound with .bind vs .live/.delegate

Reported by: cowboy Owned by: dmethvin
Priority: blocker Milestone: 1.7
Component: event Version: 1.4.2
Keywords: special, event, live, bind, 1.7-discuss Cc: cowboy, SlexAxton
Blocked by: Blocking:

Description (last modified by dmethvin)

The solution could be as simple as a flag, or yet another function argument, but .setup, .add, .teardown, and .remove should all have some way of knowing whether they are being called via .bind vs .live/.delegate.

I've made some attempts at inference here (view the console): http://jsfiddle.net/cowboy/f5rkz/

But that's clearly less than ideal, especially when you need to maintain a cache of elements internally, like in this example (imagine trying to make this work for both .live/.delegate AND .bind): http://benalman.com/news/2010/03/jquery-special-events/#event-delegation

Change History (17)

comment:1 Changed 13 years ago by dmethvin

Component: unfiledevent
Type: bugenhancement

Do you have some examples where it would be convenient to have that info? I'm not familiar enough with the special events interface to know. For a case like jQuery.event.special.submit it's enough to know that the element handling the event isn't a form, but maybe that's the exception rather than the rule.

comment:2 Changed 13 years ago by SlexAxton

Cc: cowboy SlexAxton added
Keywords: special event live bind added
Milestone: 1.4.31.5
Priority: low
Status: newopen

Ben, I know you can patch this in. Wannadoit?

comment:3 Changed 13 years ago by cowboy

What I'm going to do first is try to implement this plugin in a way that works for both bind and live/delegate:

http://benalman.com/news/2010/03/jquery-special-events/#delegation-clickoutside

After that, I'll see what, if anything, needs to be done.

comment:4 Changed 12 years ago by john

Milestone: 1.next

A reduced test case would be good. Going to bring this up in the 1.7 roadmap meeting - your input would be good, cowboy!

comment:5 Changed 12 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:6 Changed 12 years ago by Rick Waldron

Description: modified (diff)

+1,

comment:7 Changed 12 years ago by jaubourg

+0, Just need to be sure we have a use case for this (I trust ben, just want to see a use case first hand before being all "Yes yes yes")

comment:8 Changed 12 years ago by ajpiano

Description: modified (diff)

+1,

comment:9 Changed 12 years ago by Timmy Willison

Description: modified (diff)

+1, I see the advantages when writing special events.

comment:10 Changed 12 years ago by dmethvin

Description: modified (diff)

+1, Seems like it could be useful to know.

comment:11 Changed 12 years ago by john

Description: modified (diff)

+1, If we can get a solid use case and code example.

comment:12 Changed 12 years ago by scottgonzalez

+0, want to see the use case first

comment:13 Changed 12 years ago by addyosmani

+1

comment:14 Changed 12 years ago by jzaefferer

+1

comment:15 Changed 12 years ago by dmethvin

Description: modified (diff)
Milestone: 1.next1.7
Owner: set to dmethvin
Status: openassigned

comment:16 Changed 12 years ago by dmethvin

Priority: lowblocker

comment:17 Changed 12 years ago by dmethvin

Resolution: fixed
Status: assignedclosed

Landed here: https://github.com/jquery/jquery/commit/5d6a1424aa182bfe25897a217550c2e585e3ed0b

Use handleObj.selector (in the handle hook, event.handleObj.selector) to determine whether this is a delegated event.

Note: See TracTickets for help on using tickets.