Side navigation
#6903 closed enhancement (fixed)
Opened August 12, 2010 03:15PM UTC
Closed September 20, 2011 12:26PM UTC
Last modified March 08, 2012 10:15PM UTC
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
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
Attachments (0)
Change History (17)
Changed August 13, 2010 12:38AM UTC by comment:1
component: | unfiled → event |
---|---|
type: | bug → enhancement |
Changed October 25, 2010 06:53AM UTC by comment:2
cc: | → cowboy, SlexAxton |
---|---|
keywords: | → special event live bind |
milestone: | 1.4.3 → 1.5 |
priority: | → low |
status: | new → open |
Ben, I know you can patch this in. Wannadoit?
Changed October 25, 2010 06:16PM UTC by comment:3
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.
Changed April 17, 2011 12:40AM UTC by comment:4
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!
Changed May 22, 2011 07:27PM UTC by comment:5
keywords: | special event live bind → special,event,live,bind,1.7-discuss |
---|
Nominating ticket for 1.7 discussion.
Changed May 22, 2011 10:05PM UTC by comment:6
description: | 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 → 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 |
---|
+1,
Changed May 23, 2011 12:09AM UTC by comment:7
+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")
Changed May 23, 2011 02:03AM UTC by comment:8
description: | 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 → 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 |
---|
+1,
Changed May 23, 2011 03:40AM UTC by comment:9
description: | 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 → 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 |
---|
+1, I see the advantages when writing special events.
Changed May 23, 2011 09:53PM UTC by comment:10
description: | 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 → 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 |
---|
+1, Seems like it could be useful to know.
Changed June 03, 2011 01:36PM UTC by comment:11
description: | 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 → 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 |
---|
+1, If we can get a solid use case and code example.
Changed June 03, 2011 03:08PM UTC by comment:12
+0, want to see the use case first
Changed June 04, 2011 10:18PM UTC by comment:13
+1
Changed June 06, 2011 03:52PM UTC by comment:14
+1
Changed July 12, 2011 02:58PM UTC by comment:15
description: | 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 → 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 |
---|---|
milestone: | 1.next → 1.7 |
owner: | → dmethvin |
status: | open → assigned |
Changed July 12, 2011 02:58PM UTC by comment:16
priority: | low → blocker |
---|
Changed September 20, 2011 12:26PM UTC by comment:17
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.