2011-05-26 38 views
0


我是Codeigniter的新手。在我的示例應用程序中,我在我的Main.php(查看文件夾)中添加了一個名爲「RegForm」的新選項卡。當我點擊RegForm選項卡時,它會加載新窗口(width ='800px'height ='500px')。我瞭解這個概念,但我不知道如何在Codeigniter中編寫代碼。當我點擊RegForm選項卡時,我在Controller文件中調用一個函數。我需要在View中調用一個函數,其中我加載了一個帶有屬性的窗口。 AMM我正確。Codeigniter:在控制器視圖中調用函數

回答

1

你可以這樣做(如果我理解正確的):

查看 'someview' 包含此鏈接:

$atts = array(
       'width'  => '800', 
       'height'  => '500', 
       'scrollbars' => 'yes', 
       'status'  => 'yes', 
       'resizable' => 'yes', 
      ); 
echo anchor_popup('mycontroller/mymethod','Click this for a popup',$atts); 

(anchor_popup是在URL幫手一個函數,,只是自動加載它,它真的有用)

在控制器 'myController的'

class Mycontroller extends CI_Controller { 

    //function index() 
    // other functions 

    function mymethod() 
    { 
     $this->load->model('mymodelforthis'); 
     $data['properties'] = $this->mymodelforthis->get_properties(); 
     $this->load->view('myview',$data); 
    } 
} 

然後,在「myvi你顯示$properties你想要的方式 希望這可以幫助,lmk

+0

+ 1爲偉大的解釋技巧! – Peter 2011-05-26 08:28:14

+0

嗨達米安,真的謝謝你回覆它工作得很好。但有一點如何忽略窗口顯示「點擊此彈出窗口」。而是直接加載視圖。有什麼辦法嗎? – Srini 2011-05-26 09:45:13

+0

那麼,如果你想要一個新的頁面而不是一個彈出窗口,只是不使用彈出窗口;)你的意思是'點擊這個彈出窗口'顯示爲頁面標題? – 2011-05-26 09:54:09

相關問題