Bug Tracker

Modify

Ticket #9393 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

Unify and DRY out event system

Reported by: dmethvin Owned by: dmethvin
Priority: high Milestone: 1.7
Component: event Version: 1.6.1
Keywords: 1.7-discuss Cc:
Blocking: Blocked by:

Description

Unify and DRY out event system: jQuery.fn.on(events, [, selector ] [, data ], handler) -- see  https://docs.google.com/document/d/1vzJ_pl_bCKAisHu15DhTQkJBNGvgycW35lJW45d9P6U/edit?hl=en

Change History

comment:1 Changed 3 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:2 Changed 3 years ago by rwaldron

+1, Absolutely.

comment:3 Changed 3 years ago by jaubourg

+1,

comment:4 Changed 3 years ago by timmywil

+1, yes

comment:5 Changed 3 years ago by timmywil

  • Priority changed from undecided to high
  • Status changed from new to open
  • Component changed from unfiled to event
  • Milestone changed from 1.next to 1.7

comment:6 Changed 3 years ago by dmethvin

+1, Genius!

comment:7 Changed 3 years ago by john

+1, Good idea!

comment:8 Changed 3 years ago by maranomynet

+1!

comment:9 Changed 3 years ago by rwaldron

  • Owner set to dmethvin
  • Status changed from open to assigned

comment:10 Changed 3 years ago by addyosmani

+1

comment:11 Changed 3 years ago by rpflorence

Not sure if these even needs to be addressed, possibly only documented, but some might expect trigger to work on events added this way, but trigger doesn't really work with event delegation. Could cause some confusion that trigger works with el.on('click', fn) but not with el.on('click', 'li > a', fn).

MooTools delegates by parsing the event name with a CSS style pseudo selector. So something like el.on('click:relay(li > a)', fn).

Makes for a simpler signature and then you could trigger 'click:relay(li > a)' and pass in a fake target to get trigger to work with this unified system, even with delegation. Just a thought, but I don't think it's all that important /shrug

Version 0, edited 3 years ago by rpflorence (next)

comment:12 Changed 3 years ago by ajpiano

+1 BLAMMO

comment:13 Changed 3 years ago by scott.gonzalez

+1, we added something simliar in jQuery UI recently; will this support a hash of event types and handlers as well?

comment:14 Changed 3 years ago by gf3

Hot,  Prototype-style, +1.

comment:15 Changed 3 years ago by dmethvin

@gf3, the history of .on goes back to  prehistoric days, I didn't realize Prototype had done it until after I had come up with the proposal. It's good to have some consistency across frameworks though.

comment:16 Changed 3 years ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to fixed

Landed for 1.7.

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.