Jquery colorbox, close colorbox after form submitted

John picture John · Jul 7, 2011 · Viewed 16.3k times · Source

Using colorbox:

http://colorpowered.com/colorbox/

Im using this to open a window up using the iframe function in colorbox. In the popup window/iframe I have a form. What Im trying to achieve is when the form is submitted I want the colorbox window to close and the parent window to refresh. Can anyone help me with this? Here is the code Im using now, when I manually close the colorbox window the parent page refreshes, but how do I tell the page inside the colorbox popup to close colorbox?

    jQuery(document).ready(function(){
        jQuery(".purchasepop").colorbox({width:"80%", height:"80%", iframe:true,
        onClosed:function(){ location.reload(true); }});
        });

Answer

John picture John · Jul 7, 2011

Ok got it to work, was referencing the wrong "variable" as I am using noconflict to load jquery. This worked:

parent.jQuery.fn.colorbox.close();