Ticket #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: | |
| 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:5 Changed 2 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:9 Changed 2 years ago by rwaldron
- Owner set to dmethvin
- Status changed from open to assigned
comment:10 Changed 2 years ago by addyosmani
+1
comment:11 Changed 2 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
comment:12 Changed 2 years ago by ajpiano
+1 BLAMMO
comment:13 Changed 2 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 22 months ago by gf3
Hot, Prototype-style, +1.
comment:15 Changed 22 months 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 20 months 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.

Nominating ticket for 1.7 discussion.