Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery colorbox, close colorbox after form submitted

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); }});
        });
like image 537
John Avatar asked Jul 07 '11 18:07

John


2 Answers

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();
like image 84
John Avatar answered Sep 22 '22 19:09

John


I used the following code to close my the color box on my cancel button click event.

jQuery(document).ready(function () {
     jQuery("#<%= btnCancel.ClientID %>").click(function () {
        parent.jQuery.colorbox.close();
     });
});
like image 33
Rodney Hickman Avatar answered Sep 21 '22 19:09

Rodney Hickman