Bug Tracker

Opened 10 years ago

Closed 10 years ago

#13619 closed feature (duplicate)

Adding a event to the begging of event stack

Reported by: [email protected] Owned by: [email protected]
Priority: undecided Milestone: None
Component: unfiled Version: 2.0b2
Keywords: Cc:
Blocked by: Blocking:


being able to bind events that get placed at the beginning of the event stack.

i made a quick mod to the events to get the desired behaviour, and might be good to put in.

example 1 :: normal event order var t = $('<div/>'); t.on('test', function(){console.log('FIRST');}); t.on('test', function(e){ e.stopImmediatePropagation(); console.log('last');}); t.trigger('test'); FIRST last

example 2 :: adding a event before the others var t = $('<div/>'); t.on('test', function(){console.log('FIRST');}); t.on('~test', function(e){ e.stopImmediatePropagation(); console.log('last');}); t.trigger('test'); last

code: in events:add


type = ( selector ? special.delegateType : special.bindType )


var placeFirst = type[0] === '~'; if(placeFirst){

type = type.substr(1);



handlers.push( handleObj );



handlers.unshift( handleObj );


handlers.push( handleObj );


Change History (2)

comment:1 Changed 10 years ago by timmywil

Owner: set to [email protected]
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/. Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 10 years ago by timmywil

Resolution: duplicate
Status: pendingclosed

Duplicate of #7548.
Sorry, I didn't read this closely. I just saw the pasted code and asked for a test case. However, this is not something that will be added to core.

Note: See TracTickets for help on using tickets.