2010-03-17 7 views
0

mysite에 jQuery 탭을 구현 중입니다. 탭 중 하나가 양식을 보유하고 있으며 이것이 내 문제입니다. 양식은 사이트 전체에 걸쳐 여러 번 사용되므로 ajax를 통해로드됩니다. 내 문제는 양식이 제출 될 때 페이지가 탭 영역을 떠난 반면 탭이있는 시스템에는 있어야한다는 것입니다. 다음은 jquery tabs with form help

내가 사용하고있는 코드입니다

탭 HTML

<div id="tabs"> 
       <ul> 
        <li><a href="#tabs-1">Active Categories</a></li> 
        <li><a href="#tabs-2">De-activated Categories</a></li> 
        <li><a href="<?=base_url();?>admin/addCategory">Add A New Category</a></li> 
       </ul> 

FORM 태그

<div id="contact_form"> 
<?php 
    // open the form 
    echo form_open(base_url().'admin/addCategory'); 
     // categoryTitle 
     echo form_label('Category Name', 'categoryTitle'); 
     echo form_error('categoryTitle'); 
     $data = array(
      'name' => 'categoryTitle', 
      'id' => 'categoryTitle', 
      'value' => $categoryTitle, 
     ); 
     echo form_input($data); 


     // categoryAbstract 
     $data = array(
      'name' => 'categoryAbstract', 
      'id' => 'categoryAbstract wysiwyg', 
      'value' => $categoryAbstract, 
     ); 
     echo form_label('Category Abstract', 'categoryAbstract'); 
     echo form_error('categoryAbstract'); 
     echo form_textarea($data); 
     // categorySlug 
     $data = array(
      'name' => 'categorySlug', 
      'id' => 'categorySlug', 
      'value' => $categorySlug, 
     ); 
     echo form_label('Category Slug', 'categorySlug'); 
     echo form_error('categorySlug'); 
     echo form_input($data); 
     // categoryIsSpecial 
     /*$data = array(
      'name' => 'categoryIsSpecial', 
      'id' => 'categoryIsSpecial', 
      'value' => '1', 
      'checked' => $checkedSpecial, 
     ); 
     echo form_label('Is Category Special?', 'categoryIsSpecial'); 
     echo form_error('categoryIsSpecial'); 
     echo form_checkbox($data);*/ 
     // categoryOnline 
     $data = array(
      'name' => 'categoryOnline', 
      'id' => 'categoryOnline', 
      'value' => '1', 
      'checked' => $checkedOnline, 
     ); 
     echo form_label('Online?', 'categoryOnline'); 
     echo form_checkbox($data); 
     echo form_error('categoryOnline'); 
     //hidden field check if we are adding or editing 
     echo form_hidden('edit', $edit); 
     echo form_hidden('categoryId', $categoryId); 
     // categorySubmit 
     $data = array('class' => 'submit', 'id' => 'submit', 'value'=>'Submit', 'name' => 'categorySubmit'); 
     echo form_submit($data); 
     echo form_close(); 
    ?> 
</div> 

FORM 과정

function saveCategory() { 
    $data = array(); 
     // we need to set the what element the form errors get displayed in 
     $this->form_validation->set_error_delimiters('<div class="formError">', '</div>'); 
     // we need to estabilsh some rules so the form can be submitted without error, 
     // or if there is error then the form needs show errors. 
     $config = array(
        array(
         'field' => 'categoryTitle', 
         'label' => 'Category title', 
         'rules' => 'required|trim|max_length[25]|xss_clean' 
         ), 
        array(
         'field' => 'categoryAbstract', 
         'label' => 'Category abstract', 
         'rules' => 'required|trim|max_length[150]|xss_clean' 
         ), 
        array(
         'field' => 'categorySlug', 
         'label' => 'Category slug', 
         'rules' => 'required|trim|alpha|max_length[25]|xss_clean' 
         ), 
        /*array(
         'field' => 'categoryIsSpecial', 
         'label' => 'Special category', 
         'rules' => 'trim|xss_clean' 
         ),*/ 
        array(
         'field' => 'categoryOnline', 
         'label' => 'Category online', 
         'rules' => 'trim|xss_clean' 
         ) 
       ); 
     $this->form_validation->set_rules($config); 
     // with the validation rules set we can no run the validation rules over the form 
     // if any the validation returns false then the error messages will be returned to the view 
     // in the delimiters that we set further up the page. 
     if($this->form_validation->run() == FALSE) { 
      // we should reload the form 
      $this->load->view('admin/add_category'); 
     } 
} 

답변

0

이 같은 것을 사용할 수 있습니다 ... 당신이 JQuery와 UI 탭을 사용하는 경우 ...,

<input type="hidden" name="selected" value="2" /> // value=2 if you want third tab selected... 0 if first.... 
0

당신은 아약스를 사용하여 양식을 제출해야하며, 그만큼 n 폼 대신 응답을 렌더링합니다.

또는 iframe 내부에 양식이로드되도록 iframe을 배치 할 수 있습니다.

$('.selector').tabs({ selected: <?=$_POST[selected]?$_POST[selected]:0?> }); 

다음 양식, 당신은 뭔가를해야합니다