I have a parent window from where I am opening a pop-up window using window.open() and I am monitoring the return of that pop-up window using the window.opener method. I have two queries here:
- On my pop-up window, there is a submit button that takes care of the submit functionality of the form and I would like to wait for the submit to complete and close this pop-up window on submission.
- When the form is submitted and the pop-up window is closed, I am fetching one of the text box values and using that in my parent window to simulate a search automatically as soon as the pop-up window is closed.
Code:
// parent window handling of information returned from the pop-up window
function HandlePopupResult(value) {
alert("The field value is: " + value);
$("input[value='Search']").trigger("click");
}
//pop-up window handling of information to be returned to the parent window on submission
$("#myForm").submit(function() {
window.opener.HandlePopupResult($("#field").val());
window.close();
});
So my question is: How can I make sure that the submit is completed in order for me to trigger a search click in my parent window and close this pop-up window? Kindly let me know.
I am able to finally send information back to my parent form properly but I just need to make sure that my submit gets completed. Any suggestions on making sure that I fire my events only after the submit is successful?
Cheers.