Reputation: 5462
I'm working on an application where I'm using JS to inject some elements into the DOM. I have a javascript function that I can't change the code for as it's part of a 3rd party install I don't have access to - it also changes the HTML content of the page when called. I can access it For simplicity's sake, I'll omit the detailed code and substitute with example code below.
cant_change() is fired during an event I don't have access to.
function I can't change
function cant_change() {
return "can't change";
}
function I can change
function will_change() {
return "will change";
}
The specific question I have is: How can I fire the function will_change after cant_change fires? I can use jQuery too if that helps.
Upvotes: 0
Views: 68
Reputation: 140
If function cant_change
doesn't have any kind of event that you can listen to, and you can replace it with another function, you could do a workaround and encapsulate it inside another function and call both cant_change and will_change:
function encapsulated() {
cant_change();
will_change();
}
Upvotes: 2
Reputation: 342
The easy answer is that you can't.
However, most well designed third party JS plugins will give you the option to attach functions to various events that they will then call for you. I would suggest you look through the documentation for the plugin you're using and specifically look for events that they trigger, and how to use them.
Hopefully they will have one for what you're trying to do.
Upvotes: 1