title: Codeigniter Re-populate form in JQuery Colorbox when serverside validation fails
body: <p>I am creating a basic CRUD. All works fine except form repopulation. Here is the detail what i am doing.</p>
  
  <p>I am displaying a list of all employees. There are some links Add New. And Edit and Delete with each employee. Now on Add New or Edit i populate jquery Colorbox and load my form in it. Here is the link that hits my controller method.</p>
  
  <pre><code>&lt;a 
      href="&lt;?php echo site_url('employees/form/'.$employee['id']);?&gt;" 
      id="popUpEditFormTrigger" 
      return="&lt;?php echo site_url('employees/entries'); ?&gt;"
  &gt;Add New&lt;/a&gt;
  </code></pre>
  
  <p>As you can see here i am hitting a controller method to load a form. This works fine. In color box form.js here is some code.</p>
  
  <pre><code>var dataString = $('#updateForm').serialize();
  var url = $('#updateForm').attr('url');
  $.ajax({
      type: "POST",
      url: url,
      data: dataString,
      success: function() {                
          $.fn.colorbox.close();                
      }
  }); 
  return false;
  </code></pre>
  
  <p>it closes the color box when ajax is successsfull. return false prevents the list view to go further and then</p>
  
  <pre><code>return="&lt;?php echo site_url('employees/entries'); ?&gt;"
  </code></pre>
  
  <p>is run and refreshes the entries in table.</p>
  
  <p>Controller</p>
  
  <pre><code>public function submit()
  {
      $this-&gt;load-&gt;library('form_validation');
  
      $this-&gt;form_validation-&gt;set_rules('name',' Employee Name'.'trim|required');
      $this-&gt;form_validation-&gt;set_rules('salary',' Salary'.'trim|required');
      $this-&gt;form_validation-&gt;set_rules('description',' Description'.'trim|required');
  
      if($this-&gt;form_validation-&gt;run()){
          $data['name']           =   $post['name'];
          $data['salary']         =   $post['salary'];
          $data['description']    =   $post['description'];
  
          $result =   $this-&gt;employeesModel-&gt;insertEmployee($data);
      }else{
          $this-&gt;load-&gt;view('employee_form');
      }
  }
  </code></pre>
  
  <p>Problem :</p>
  
  <p>The problem is that i want to repopulate form in colorbox so that i can display the user validation errors. But the colorbox is always closes whether insertion is performed or validation fails. I want if the validation fails populate the form again in colorbox and prevent hyper link attribute return to go to site_url('employees/entries'). How can i do that? I am sure JQuery can handle this but i don't know how. Suggestions required.</p>