javascript - can you bind .click() so that it fires prior to onclick? -
javascript - can you bind .click() so that it fires prior to onclick? -
i'm writing jquery app that's beingness build in jsf. jsf components using lot of own js doing whatever jsf , utilize lot of onclick attributes handle all.
is there valid/proper way bind own click event element , ensure event fires prior default onclick event? appears default jquery click function fired after inline onclick function calls.
in jquery events triggered strictly in order in registered.
you can circumvent inline dom0 onclick style handlers iterating on whole dom, removing onclick properties, , registering own handler then invokes defined function.
something like:
$('[onclick]').each(function() { var handler = $(this).prop('onclick'); $(this).removeprop('onclick'); $(this).click(handler); }); see http://jsfiddle.net/alnitak/2sctk/
so, register own handlers first jquery, invoke code above remove original inline onclick handlers , re-register them if jquery had added them.
edit code simplified utilize original function - jquery ensure function invoked right context. previous code explicitly set context window incorrect.
javascript jquery jsf click onclick
Comments
Post a Comment