Bug Tracker

Modify

Ticket #11934 (closed feature: wontfix)

Opened 11 months ago

Last modified 6 months ago

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:
Blocking: Blocked by:

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

comment:1 Changed 11 months ago by dmethvin

  • Status changed from new to open
  • Component changed from unfiled to event
  • Priority changed from undecided to low
  • Milestone changed from None to 1.9
  • Keywords 1.9-discuss added
  • Type changed from enhancement to feature

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.

comment:2 Changed 11 months ago by getify

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 8 months ago by dmethvin

-1, This doesn't fit in at all with our string event syntax, and the colon char is used by frameworks.

comment:4 Changed 8 months ago by mikesherov

-1, Seems almost too late for jQuery to do this now.

comment:5 Changed 8 months ago by gibson042

-1, I'd rather not mix extra logic into event type.

comment:6 Changed 7 months ago by mikesherov

-1

comment:7 Changed 7 months ago by rwaldron

-1, No new custom selectors. No new event system complexities

comment:8 Changed 7 months ago by gibson042

-1

comment:9 Changed 7 months ago by gnarf

-1, Dave brings up points I agree with

comment:10 Changed 7 months ago by mikesherov

  • Status changed from open to closed
  • Resolution set to wontfix

comment:11 Changed 6 months ago by dmethvin

  • Milestone changed from 1.9 to None

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.