How can I execute a method in opener window from a modal window?
-
21-06-2021 - |
Question
I'm using a jQuery plugin for notifications: http://needim.github.com/noty/
This is the way I call the method that displays the notification:
noty({force: true, timeout: false, text: 'Hello noty', type: 'information'});
The code works fine, but now, being in a modal window, I need to execute that call in the opener window as soon as I close the modal window... I think I should use window.opener but don't know how to do it for this case.
Solution
you could define a JS function in your opener window:
function invokeSuccessNotification(msg){
noty({force: true, timeout: false, text: 'Hello noty', type: 'information'});
}
then, in your modal window, call that method like this:
window.opener.invokeSuccessNotification();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow