1

$(element).data("events") gives me a list of all the events for element. Considering that I need to bind an event and have it fire before another one already bound to it, how can I accomplish that?

I have thought of unshifting an event to the list returned from $(element).data("events").myevent, but I'm guessing that's not the right approach.

Thank you.

josemota
  • 974
  • 1
  • 8
  • 27
  • put second one inside first :-) – zod Apr 11 '12 at 15:56
  • In a previous [question](http://stackoverflow.com/questions/2360655/jquery-event-handlers-always-execute-in-order-they-were-bound-any-way-around-t) your proposed method was the accepted answer. Seems neat and clean enough. – Snuffleupagus Apr 11 '12 at 16:11
  • @user1090190 looks like a nice approach, thank you. Extracting behavior is what I need for modularity purposes. – josemota Apr 11 '12 at 16:51
  • @josemota the answer u1090190 pointed out is now 2 years old. Since then jQuery has acquired [jQuery.Callbacks](http://api.jquery.com/jQuery.Callbacks/) - "a multi-purpose callbacks list object that provides a powerful way to manage callback lists". You might consider this as an alternative approach to meeting your ends. – Beetroot-Beetroot Apr 11 '12 at 17:35

0 Answers0