title: Close iframe in colorbox after submit the form
body: <p>I'm developing a site where on first visit, the user will be asked to input an email and which city he/she lives. I loaded it using colorbox and iframe. Here is the code in main.php :</p>
  
  <pre><code>Yii::app()-&gt;clientScript-&gt;registerScript('',
                  "$('document').ready(
                      function()
                      {
                              $.fn.colorbox({href:'http://www.veevou.com/visitor/create',
                              iframe:true,'width':'365px', 'height':'510px', onClosed:function(){ location.reload(true); }});                                
                      }
                  )");
  
                  $colorbox = $this-&gt;widget('application.extensions.colorpowered.ColorBox');
                  $colorbox
                      -&gt;addInstance('.colorbox', array('maxHeight'=&gt;'80%', 'maxWidth'=&gt;'80%'));
  </code></pre>
  
  <p>So, you see, the colorbox will render the page create.php and after the form is submitted, the controller will save the data then redirect to index page. </p>
  
  <p>This is the controller :</p>
  
  <pre><code>if(isset($_POST['Visitor']))
  {
         $model-&gt;attributes=$_POST['Visitor'];
  
                 // Register only if he / she is not registered as member nor visitor
                 if($model-&gt;save())
                 {
                 echo "&lt;script&gt;parent.$.fn.colorbox.close(); &lt;/script&gt;";
                 $this-&gt;redirect(array('site/index'));
                 }
  
  }
  else
  {
          $this-&gt;render('form',compact('model'));
  }
  </code></pre>
  
  <p>But it says "cannot modify headers already sent..." . How to close the colorbox ? I have tried to put the "parent.$.fn.colorbox.close(); " before redirecting to another page but it didnt work. Where should i put the $.fn.colorbox.close() ? I have tried several methods in another post but none works for me. Thanks</p>