0

codeigniter を使用してフォームを送信しようとしていて、javascript でフォームを閉じようとしています…</p>

親ページから呼び出すポップアップ関数があります。

<a href = "javascript:popup('controller/method/variable', 'Click', '400', '400')">Click</a> 

そしてここに関数があります:

function reject_popup(url, name, width, height){
    var top = parseInt((screen.availHeight / 2) - (height / 2));
    var left = parseInt((screen.availWidth / 2) - (width / 2));
    var features = "location=1, status=1, scrollbars=1, width=" + width + ", height=" + height + ", top=" + top + ", left=" + left;
  window.open(url, name, features);} 

次のフォームが開きます。

<?php echo form_open('state/validate_rejection/'.$file_results->sender_id.'/'.$this->session->userdata('id').'/'.$file_results->id, array('name'=>'rejection_form', 'id'=>'rejection_form', 'onsubmit'=>'window.forms[0].submit();self.close();')); ?>

<p>
    <label>Write the reason of Rejection?<span class='req'>* Required</label>
    <textarea name="remarks" rows="8"  max-width:380px " autofocus required></textarea>
</p>

<input type="button" class="button" value="cancel"  />
<input name="submit_rejection" id="submit_rejection" type="submit" class="button" value="Send" />

ご覧のとおり、フォームアクションはコントローラー/メソッドに移動するURLです:ここに私が使用するメソッドがあります:

function validate_rejection(){
     $this->form_validation->set_rules('remarks', 'Remarks', 'trim|required');
     if($this->form_validation->run() == TRUE){
         $sender_id = $this->uri->segment(3) ? $this->uri->segment(3) : 0;
         $user_id = $this->uri->segment(4) ? $this->uri->segment(4) : 0;
         $file_id = $this->uri->segment(5) ? $this->uri->segment(5) : 0;
    //here a function from codigniter model is called, and returns true if query succeded, false if it failed
         $rejection = $this->files_model->reject_file($sender_id, $user_id, $file_id);

         if($rejection == TRUE){

             $this->session->set_flashdata('rejection_succ', 'Rejected Successfully');
             //redirect('home');
         }
         else{
              $this->session->set_flashdata('rejection_fail', 'Rejection of file Failed');
         }
      }
      else{
           $this->session->set_flashdata('remarks_validation_errors', validation_errors());
      }
  } 

nd フォームの送信が成功または失敗した場合、flashdata が設定されます

フォームが送信されたら、フォームが完了したかどうかを確認し、親ページをリロードしてポップアップを閉じるようにしたいのですが…。誰でも私がそれを達成するのを手伝ってくれませんか...これもjavascriptのケースですが、私がcodeigniterで作業している限り、これがこのスレッドを投稿するのに最適な場所になると思いましたか?

注:フォーマットが悪くてすみません...新しいユーザーで、コードブロックが表示されませんでした:S

4

2 に答える 2

0

もし私があなただったら、jQuery Dialog - http://jqueryui.com/dialog/#modal-formを使用します。すでに存在する場合、なぜ温水を再発明するのですか。追加する必要があるのは、ページを更新することだけです。

于 2013-06-28T15:19:51.580 に答える