jquery - Forcing to run a custom function befor run the assigned event handlers of an element -
imagine jquery plugin insert element (such image) page , image has event handler click event. example when click image open 1 popup div.
an other hand wrote function in page. example function slow fade textbox (input tag).
so have:
- a jquery plugin
- an image added jquery plugin -->>> id ="myimage"
- click event of image causes --->> popup div
- an input tag --->> id="myinput"
- my function hide input --->> hideslowinput()
important note: don't want change plugin. want override event handler of image without change plugin.
edit: have not codes open popupdiv, start plugin in $(document).ready
now, how can force open popup div after running function every time click image???
following @ejay's comment
this not possible, @ least, not publicly supported in documentation {nothing can find...}
but if plugin talking using jquery bind open popup div handler, can try this:
//declare function function myfunction(){ alert('ok'); } //bind click handler image class 'myclass' $('.myclass').click(myfunction); //set handler in first keeping other bound events var myh = $._data( $(".myclass")[0], "events" ).click.pop(); $._data( $(".myclass")[0], "events" ).click.unshift(myh);
if there no other click handler, reverse order:
[].reverse.call($._data($('.myclass')[0]).events.click);
see generic demo here
Comments
Post a Comment