Side navigation
#11934 closed feature (wontfix)
Opened June 19, 2012 08:32PM UTC
Closed October 29, 2012 05:04PM UTC
Last modified November 27, 2012 05:40PM UTC
Enhancement: allow ":once" on event names to indicate one() variant event binding
Reported by: | getify | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | event | Version: | 1.7.2 |
Keywords: | 1.9-discuss | Cc: | |
Blocked by: | Blocking: |
Description
I am a big fan of the "one()" functionality. But I have a suggestion for a small piece of sugar to extend it:
Allow me to put ":once" on the end of any event name in any of the event binding APIs (bind, on, etc) which tells jQuery to use the "one()" variant for the binding of that particular event. For example:
$("a").bind("click:once",handle) // vs. $("a").one("click",handle)
$("#foobar").on("mousedown:once mouseup","a",handle) // vs. $("#foobar").one("mousedown","a",handle).on("mouseup","a",handle)
Attachments (0)
Change History (11)
Changed June 23, 2012 01:39PM UTC by comment:1
component: | unfiled → event |
---|---|
keywords: | → 1.9-discuss |
milestone: | None → 1.9 |
priority: | undecided → low |
status: | new → open |
type: | enhancement → feature |
Changed June 23, 2012 01:45PM UTC by comment:2
FWIW, Mootools has a whole system of "Event Pseudos", including ":once"...
http://mootools.net/docs/more/Class/Events.Pseudos
Perhaps that's a pattern jQuery could consider for this.
Changed September 24, 2012 05:08PM UTC by comment:3
-1, This doesn't fit in at all with our string event syntax, and the colon char is used by frameworks.
Changed September 24, 2012 05:13PM UTC by comment:4
-1, Seems almost too late for jQuery to do this now.
Changed September 27, 2012 12:22PM UTC by comment:5
-1, I'd rather not mix extra logic into event type.
Changed October 14, 2012 10:29PM UTC by comment:6
-1
Changed October 14, 2012 11:24PM UTC by comment:7
-1, No new custom selectors. No new event system complexities
Changed October 22, 2012 05:18PM UTC by comment:8
-1
Changed October 22, 2012 05:26PM UTC by comment:9
-1, Dave brings up points I agree with
Changed October 29, 2012 05:04PM UTC by comment:10
resolution: | → wontfix |
---|---|
status: | open → closed |
Changed November 27, 2012 05:40PM UTC by comment:11
milestone: | 1.9 → None |
---|
There might be a case to be made for a CSS-selectors-like handling of the event string, but I'm not a fan of making an exception for ":once" alone. Also, many external users are now using the ":" character in their custom event strings so we would need to be very careful about creating compatibility issues. I'll mark it for 1.9 discussion.