views:

243

answers:

1

Hi all,

I am trying to figure out how to trigger the default action before something else happens. Specifically, I am using a third party library, and if I use a event handler, and call one of their functions, they override the default action. Therefore, as a work around, i want the default action happen before their library function is called.

Is there anyway of doing that?

Thank you very much!

+2  A: 

I assume that you mean that you want to call their function after the event is processed by the browser.

To do that, use the setTimeout method to execute after a delay.

For example,

//In the event handler:
setTimeout(function() {
    //This code will execute 5 milliseconds later, and only after your code finishes.
    //Call their function here
}, 5);  //That means a 5 millisecond delay.
        //You can increase it if you want to.
SLaks