views:

693

answers:

5

Hello guys,

On a given webpage I have a link that opens a modal window using Thickbox. In that window I have a form which I use to save some data. After I submit the form, I close the modal window. Now my question is: can I refresh the main page after closing the modal window?

Thank you.

A: 

Please describe how the modal window is constructed? Is it with window.open or it's just an absolute positioned DIV?

stoimen
Psyche
A: 

Call this after the form is submitted and before the window is closed:

window.opener.location.reload();
Trevor
A: 

Suppose this is the div you show in modal mode. You have to call tb_remove() to close the modal window. So just use location.reload(); before that call.

<div id="modalContent" style="display:none">
  <form>
    ...
  </form>
  <p style="text-align:center">
    <input type="submit" id="Login"value="Click to close"
      onclick="window.opener.location.reload();tb_remove()" />
  </p>
</div>
jitter
I'm afraid I have to modify Thickbox source in order to add that piece of code.
Psyche
Why? What makes you think that
jitter
Because I can't edit the source in order to add that code just for that page.
Psyche
A: 

Actually Thickbox is no longer being maintained, so it might be better to use a different modal window. That being said, I know Facebox allows you to bind box open and close events like this:

$(document).bind('close.facebox', function() {
 // do something here
})
fudgey
Will try this one, thanks.
Psyche
A: 

If using facebox simply add window.location.reload(); around line 148, so you end up with something like... close: function() { $(document).trigger('close.facebox'); window.location.reload(); return false }

If still using Thickbox I'm sure it's just as easy. Do a search for "close" and add the code.

Model Reject