Ticket #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 |
| Blocking: | Blocked by: |
Description (last modified by dmethvin) (diff)
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
comment:1 Changed 3 years ago by dmethvin
- Type changed from bug to enhancement
- Component changed from unfiled to event
comment:2 Changed 3 years ago by SlexAxton
- Cc cowboy, SlexAxton added
- Keywords special event live bind added
- Priority set to low
- Status changed from new to open
- Milestone changed from 1.4.3 to 1.5
Ben, I know you can patch this in. Wannadoit?
comment:3 Changed 3 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 2 years ago by john
- Milestone set to 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 2 years ago by john
- Keywords special,event,live,bind,1.7-discuss added; special event live bind removed
Nominating ticket for 1.7 discussion.
comment:7 Changed 2 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:9 Changed 2 years ago by timmywil
- Description modified (diff)
+1, I see the advantages when writing special events.
comment:10 Changed 2 years ago by dmethvin
- Description modified (diff)
+1, Seems like it could be useful to know.
comment:11 Changed 2 years ago by john
- Description modified (diff)
+1, If we can get a solid use case and code example.
comment:12 Changed 2 years ago by scott.gonzalez
+0, want to see the use case first
comment:13 Changed 2 years ago by addyosmani
+1
comment:14 Changed 2 years ago by jzaefferer
+1
comment:15 Changed 2 years ago by dmethvin
- Owner set to dmethvin
- Status changed from open to assigned
- Description modified (diff)
- Milestone changed from 1.next to 1.7
comment:17 Changed 21 months ago by dmethvin
- Status changed from assigned to closed
- Resolution set to fixed
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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.