#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 )
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
Component: | unfiled → event |
---|---|
Type: | bug → enhancement |
comment:2 Changed 13 years ago by
Cc: | cowboy SlexAxton added |
---|---|
Keywords: | special event live bind added |
Milestone: | 1.4.3 → 1.5 |
Priority: | → low |
Status: | new → open |
Ben, I know you can patch this in. Wannadoit?
comment:3 Changed 13 years ago by
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
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:7 Changed 12 years ago by
+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 12 years ago by
Description: | modified (diff) |
---|
+1, I see the advantages when writing special events.
comment:10 Changed 12 years ago by
Description: | modified (diff) |
---|
+1, Seems like it could be useful to know.
comment:11 Changed 12 years ago by
Description: | modified (diff) |
---|
+1, If we can get a solid use case and code example.
comment:15 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.next → 1.7 |
Owner: | set to dmethvin |
Status: | open → assigned |
comment:16 Changed 12 years ago by
Priority: | low → blocker |
---|
comment:17 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.
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.