Monday, 15 February 2010

event handling - How significant is the order with jQuery's trigger-method? -



event handling - How significant is the order with jQuery's trigger-method? -

i want provide way utilize on-event handler outside of plugin. problem is, trigger not fired if provide them in wrong order.

for example, works:

$(window).on('foo:bar', function(){ alert(true); }); $(window).trigger('foo:bar');

...this, not:

$(window).trigger('foo:bar'); $(window).on('foo:bar', function(){ alert(true); });

any ideas how sec approach can work?

update

here works: http://www.benplum.com/projects/rubberband/

you cannot. want eat cake before baking it.

upd: you're misinterpreting code @ http://www.benplum.com/projects/rubberband/

here jsfiddle proof doesn't work you're thinking: jsfiddle.net/zerkms/z5mya/

note code: i've forked library , added trivial console.log here: https://github.com/zerkms/rubberband/blob/master/jquery.bp.rubberband.js#l77

event-handling jquery jquery-on

No comments:

Post a Comment