Using a callback function with subModal
I get a lot of questions regarding the use of a callback function with my subModal code. The following is an except from a response I posted over at the subModal google group.
- Define the function that’ll be called on the opening page.
- Pass the function you’d like to call into ‘showPopWin’.
- Assign any return value on the modal page itself, if necessary
- Call the hidePopWin function passing true
It might be easier to grok in code, so as an example…
On the subModal opening page
// returnVal can get passed in from the modal page itself...
//....see below for info
function returnRefresh(returnVal) {
window.document.reload();
}
// Open the modal, passing in the refresh function
// as a reference NOT a string.
showPopWin('mymodal.html', 500, 500, returnRefresh);
From inside the subModal window
// If you plan to pass a return value assign it
var returnVal = "something";
// When you're ready to close the pop window
// call this...Passing true makes sure the return
// function gets called.
window.top.hidePopWin(true);

