Bug Tracker

Ticket #6903 (closed enhancement: fixed)

Opened 5 years ago

Last modified 3 years ago

special events need a way to determine whether they are being bound with .bind vs .live/.delegate

Reported by: cowboy Owned by: dmethvin
Priority: blocker Milestone: 1.7
Component: event Version: 1.4.2
Keywords: special,event,live,bind,1.7-discuss Cc: cowboy, SlexAxton
Blocking: Blocked by:

Description (last modified by dmethvin) (diff)

The solution could be as simple as a flag, or yet another function argument, but .setup, .add, .teardown, and .remove should all have some way of knowing whether they are being called via .bind vs .live/.delegate.

I've made some attempts at inference here (view the console):  http://jsfiddle.net/cowboy/f5rkz/

But that's clearly less than ideal, especially when you need to maintain a cache of elements internally, like in this example (imagine trying to make this work for both .live/.delegate AND .bind):  http://benalman.com/news/2010/03/jquery-special-events/#event-delegation

Change History

comment:1 Changed 5 years ago by dmethvin

  • Type changed from bug to enhancement
  • Component changed from unfiled to event

Do you have some examples where it would be convenient to have that info? I'm not familiar enough with the special events interface to know. For a case like jQuery.event.special.submit it's enough to know that the element handling the event isn't a form, but maybe that's the exception rather than the rule.

comment:2 Changed 5 years ago by SlexAxton

  • Cc cowboy, SlexAxton added
  • Keywords special event live bind added
  • Priority set to low
  • Status changed from new to open
  • Milestone changed from 1.4.3 to 1.5

Ben, I know you can patch this in. Wannadoit?

comment:3 Changed 5 years ago by cowboy

What I'm going to do first is try to implement this plugin in a way that works for both bind and live/delegate:


After that, I'll see what, if anything, needs to be done.

comment:4 Changed 4 years ago by john

  • Milestone set to 1.next

A reduced test case would be good. Going to bring this up in the 1.7 roadmap meeting - your input would be good, cowboy!

comment:5 Changed 4 years ago by john

  • Keywords special,event,live,bind,1.7-discuss added; special event live bind removed

Nominating ticket for 1.7 discussion.

comment:6 Changed 4 years ago by rwaldron

  • Description modified (diff)


comment:7 Changed 4 years ago by jaubourg

+0, Just need to be sure we have a use case for this (I trust ben, just want to see a use case first hand before being all "Yes yes yes")

comment:8 Changed 4 years ago by ajpiano

  • Description modified (diff)


comment:9 Changed 4 years ago by timmywil

  • Description modified (diff)

+1, I see the advantages when writing special events.

comment:10 Changed 4 years ago by dmethvin

  • Description modified (diff)

+1, Seems like it could be useful to know.

comment:11 Changed 4 years ago by john

  • Description modified (diff)

+1, If we can get a solid use case and code example.

comment:12 Changed 4 years ago by scott.gonzalez

+0, want to see the use case first

comment:13 Changed 4 years ago by addyosmani


comment:14 Changed 4 years ago by jzaefferer


comment:15 Changed 4 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned
  • Description modified (diff)
  • Milestone changed from 1.next to 1.7

comment:16 Changed 4 years ago by dmethvin

  • Priority changed from low to blocker

comment:17 Changed 4 years ago by dmethvin

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

Landed here:  https://github.com/jquery/jquery/commit/5d6a1424aa182bfe25897a217550c2e585e3ed0b

Use handleObj.selector (in the handle hook, event.handleObj.selector) to determine whether this is a delegated event.

Note: See TracTickets for help on using tickets.