Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close ColorBox iFrame after submit

I'm using jQuery ColorBox to display a shopping cart item. When a user enters the quantity in the iFrame (opened with colorbox) and clicks on the submit button, I want the iFrame to be close and main window (parent) to be refreshed automatically.

I mean I want two things after submitting data on iFrame:

  1. iFrame closes automatically.
  2. Parent window getting refresh automatically.

Please help me out.

like image 705
diEcho Avatar asked Jan 05 '10 23:01

diEcho


4 Answers

use this on the parent window while opening iframe:

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

and this to close the iframe inside iframe page:

parent.$.fn.colorbox.close();
like image 170
nik Avatar answered Oct 22 '22 20:10

nik


After the form is submitted in Frame 1, you can use the following JavaScript to reload the parent frame:

window.parent.location.reload(true);
like image 29
barsh Avatar answered Oct 22 '22 20:10

barsh


<form target="_top">
like image 2
Amien Avatar answered Oct 22 '22 18:10

Amien


open jquery.colorbox.js find these two pieces of code:

$close.click(function () {
  publicMethod.close(); 
});


$overlay.click(function () {
  if (settings.overlayClose) {
    publicMethod.close();
  }
});

replace with these - note the addition of " window.location.reload();"

$close.click(function () {
  publicMethod.close();
  window.location.reload();         
});


$overlay.click(function () {
  if (settings.overlayClose) {
    publicMethod.close();
    window.location.reload();
  }
});
like image 2
Rohan4 Avatar answered Oct 22 '22 19:10

Rohan4