javascript - Ensure jQuery event handler execution order -
javascript - Ensure jQuery event handler execution order -
i think event handlers processed in order registered. (is correct?) if case if attach event handler @ origin of script, can absolutely fire before subsequent handlers attached same event? event namespaces have effect on this? event handlers fired in series (one finishes before next) or in parallel?
i want because script relies on viewport size, changes on resize event, , need it. rather calling $(window).width()
repeatedly in each of handler functions, i'd set handler @ top of script saves $(window).width()
object property on each resize. in subsequent handlers can access property , recent measurement.
i know create custom event triggers calculation done , attach subsequent handlers custom event. but, i'd don't want because need maintain interoperability plugins come after mine may attaching resize event.
if attach event handler before other script has run (even plugin), callback fire first.
you can inspect array of event handlers through info object:
$(window).data('events');
note: non-documented approach , might not work eventually. utilize inspection only.
javascript javascript-events event-handling jquery
Comments
Post a Comment