Bug Tracker

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#9393 closed enhancement (fixed)

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

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 (16)

comment:1 Changed 6 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:2 Changed 6 years ago by rwaldron

+1, Absolutely.

comment:3 Changed 6 years ago by jaubourg

+1,

comment:4 Changed 6 years ago by timmywil

+1, yes

comment:5 Changed 6 years ago by timmywil

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

comment:6 Changed 6 years ago by dmethvin

+1, Genius!

comment:7 Changed 6 years ago by john

+1, Good idea!

comment:8 Changed 6 years ago by maranomynet

+1!

comment:9 Changed 6 years ago by rwaldron

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

comment:10 Changed 6 years ago by addyosmani

+1

comment:11 Changed 6 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 6 years ago by rpflorence (next)

comment:12 Changed 6 years ago by ajpiano

+1 BLAMMO

comment:13 Changed 6 years ago by scottgonzalez

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

comment:14 Changed 5 years ago by gf3

Hot, Prototype-style, +1.

comment:15 Changed 5 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 5 years ago by dmethvin

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

Landed for 1.7.

Note: See TracTickets for help on using tickets.