#11934 closed feature (wontfix)
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)
Change History (11)
comment:1 Changed 11 years ago by
Component: | unfiled → event |
---|---|
Keywords: | 1.9-discuss added |
Milestone: | None → 1.9 |
Priority: | undecided → low |
Status: | new → open |
Type: | enhancement → feature |
comment:2 Changed 11 years ago by
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.
comment:3 Changed 11 years ago by
-1, This doesn't fit in at all with our string event syntax, and the colon char is used by frameworks.
comment:10 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
comment:11 Changed 10 years ago by
Milestone: | 1.9 → None |
---|
Note: See
TracTickets for help on using
tickets.
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.