2011-08-03 16 views
1

jQueryダイアログを使用して、アプリケーションにファイルをアップロードするためのビューをロードしています。ファイルを参照してsubmitをクリックすると、コントローラーが呼び出され、ファイルを処理してモデルに渡して挿入します。その後、モデルはコントローラに戻り、成功したかどうかを確認し、成功のために新しいビューをロードします。Controller/ViewからjQueryダイアログをロードしますか?

ビュー全体を呼び出してロードするのではなく、同じjQueryダイアログ内で成功(または未)ビューをレンダリングしたい(または新しいビューを開く)ことができます。

コントローラ内からjQueryダイアログを呼び出す(何とか)必要がありますか?または、私のコントローラに新しいビューを呼び出させて、ロードしたらダイアログをレンダリングしてもらいますか?基本的にはダイアログに表示されますか?これが理にかなってほしい。

ありがとうございました。

**編集:下記のコードを追加してください+コメントありがとうございます! **

私のintialビューは、ユーザーがアンカーをクリックしたときに呼び出され、次のjQueryの機能、(「ファイルをアップロード」を参照)含まれています

$(document).ready(function(){ 
function uploadImage(event) { 
      id = $(this).data('id'); //id is an URL such as ('upload_form'/do_upload/5) it calls my controller (uploadimage), and passes a value (5) to a function (doupload) 

      $("#dialog").load(id).dialog(); //loads the URL  
     return false; 
    } 

$('.imageBtn').live('click',uploadImage);  
}); 

コントローラによって呼び出される関数:

function do_upload() 
    { 
     $config['upload_path'] = './uploads/'; 
     $config['allowed_types'] = 'gif|jpg|png'; 
     $config['max_size'] = '0'; 
     $config['max_width'] = '212'; 
     $config['max_height'] = '118'; 

     $this->load->library('upload', $config);  
     if (! $this->upload->do_upload()) 
     { 
      $data['id'] = $this->input->post('iEventID', true);  
         $data['error'] = $this->upload->display_errors(); 
      $this->load->view('admin/upload_form', $data); // If an error is found during file/img upload, then the code reloads the view that was previously loaded into my dialogue. This is where I need the same view to reload in the dialog and present the error message. This currently loads the view in its entirety in a browser window. 
     } 
     else 
     { 
      $upload_data = $this->upload->data(); 
      $filename = $upload_data['file_name'];  
      $this->event_model->addEventImage($filename); 
      $this->load->view('admin/upload_success'); // If all is well, instead of loading the view in its entirety, I want to load the success into the dialog previously popped. 
     } 
    } 
+0

いくつかのコードを見ることができますか?あなたは問題を説明するためのまともな仕事をしましたが、あなたの現在のコードを見れば、ポインタを与えるのがより明確で簡単になります。 – slandau

+0

上記のコードを追加しました。ありがとう! – user464180

答えて

0

のvar $ダイアログ内のデータをレンダリングするためのコールバック()メソッド。関数showDialog(HTML、ステータス、リクエスト){$ dialog.dialog( 'open'); $ dialog.html(html);偽を返します。 {'Ok':{{{{{{{{{{{{{{{{{{{{{{}}} { $ dialog.dialog( 'close');}、$ dialog.dialog( 'close');} {$ { ( '{popup'});} {}}}}}}}}}}}}}}}}}}} jQuery.ajax({URL: '<% = submitURL%>'、データ型: '文字列'、成功:にShowDialog、データ 'データ'、タイプ: '後'});});

couldnt format!!!

0

あなたの質問の内容は正確ではありませんが、コントローラがiFrameでビューを読み込んでダイアログにiFrameを置くことができますか?バック成功にテキストを提出し、受信する

0

使用アヤックス:ダイアログ

関連する問題