I have a function, let call it: myFunction, that I use a lot. Most of the time, I don't care when it's called. However, sometimes, it would be nice to know when it is called so that I can perform certain actions. Is there a way that I can, without editing myFunction, create a listener in jQuery so that when myFunction is done, I can call another function?
for example:
<script>
var foo = "foo";
function myFunction() {
foo += "bar";
}
function afterMyFunction() {
alert(foo);
}
$(function() {
#some sort of listener for when myFunction is done --- ???#
myFunction();
});
</script>
I would want, when the page loads, for there to be an alert that simply says "foobar". This is obviously a simplified example, but it gets my point across... I hope.