I’m trying to get a piece of our JavaScript run after some 3rd party code makes a modal dialog appear. I saw a pretty neat idea of hijacking the jQuery show function, but unfortunately it is not working. I’m guessing this idea used to work on an older version of jQuery back in 2009, but not now on the latest version. Here is a jsFiddle with the implementation and a sample:
http://jsfiddle.net/mkmurray/drv5w/2/
As you can see by running the sample, it will alert the ‘beforeShow’ event, but not the ‘afterShow event’ and with some debugging I can see that it is not calling the ‘newCallback’ function entirely.
Thank you in advance with any help you can provide.
Looks like I was able to work through a solution. It involved a few factors going wrong with the original:
easing. This really messed with how I was delegating to the originalshowmethod in jQuery by calling_oldShow.apply(...).showmethod calls a series of other methods that sometimes recursively callshowagain. I needed a way to not have my implementation intercept those recursive calls; I found that I could rely on if there was aselectorproperty or not.A working implementation can be found here at this jsFiddle:
http://jsfiddle.net/mkmurray/drv5w/27/
This implementation is pretty dependent on jQuery not changing the method signature of the
showmethod though. So you pretty much have to decide if you want to modify your 3rd party jQuery plugins instead of doing this. Either way, if you want to get latest of the 3rd party plugin or the latest jQuery, some new change could break your implementation. So this solution is not necessarily better or worse than modifying your third party plugins.