I was looking for a way to refresh the parent window on the remove event [tb_remove()] of thickbox jQuery plugin, developed by Cody Lindley, with/without modal and/or iframe popup windows. And here is what I did, hope this helps you guys too…
Step 1:
Get the unpacked/unminified version of ThickBox.js. Open it up in your favorite text editor and find the tb_remove function in the file.
|
|
Now depending on how you want the close links or thickbox’s remove/close function to behave, in all of your pop-ups, you can modify the function to take up a true/false parameter, which when set to true would refresh the parent window, and false wouldn’t. This would give you some control over which thickbox pop-ups would refresh the parent window - this is what I have done.
Step 2-A: Modifying the function to accept parameters to refresh the parent.
We just edit the function to accept a parameter, and check if the argument passed is true or false. If true, refresh the parent window. If false, don’t, just close the window.
|
|
From Line 1 to Line 6 in the above code is edited and that’s all there is to it.
Now when you call the function tb_remove(), just pass the boolean value to the function and voila your parent window would refresh.
Calling the tb_remove() function to close thickbox’s parent window is as follows:
<a href="#" onclick="window.parent.tb_remove(true);">Close</a>;
Step 2-B: Modifying the function to refresh the parent window everytime any thickbox window is closed.
In the case when you want the parent window to refresh everytime you close the thickbox, just add one line to the tb_remove function as shown below:
|
|
Note: IN Step 2B i.e. The above code will refresh the parent window every time any kind of thickbox popup is closed like, iframes, modals, etc. and is only advised if you know what your are doing.
You can also download the modified thickbox.js from my github here. This file is modified with the modifications made in Step 2-A only.