2011-07-07 22 views
0

我試圖想出一個辦法做到以下幾點視圖助手:在Kohana的

我要讓這將通過Ajax加載而且其頁面的內部部分,當頁面刷新的操作。

我用View Helper知道這ZEND框架,但不知道如何在Kohana

我是新來的Kohana做。

編輯:什麼我試圖做http://www.espncricinfo.com/west-indies-v-india-2011/engine/current/match/489228.html?CMP=chrome

在上述網頁時整個網頁加載即時比分板上裝有它 例。但是當你點擊「刷新記分牌」按鈕時,只有通過ajax替換現場記分板。

我想創建一個動作,說action_scoreboard這將用於記分牌數據。而action_index要加載整個頁面,但在action_index的視圖中,我需要撥打action_scoreboard

感謝

回答

0

我用Kopjax - Pjax jQuery ajax模塊。其代碼可在gitgub

0

不知道這是要做到這一點的最好辦法,但是這是我怎麼樣去處理這種情況。

public function action_index($raw = 0) { 
    $records = Jelly::select('scores')->execute(); 

    if ($raw == 0) { 
     $view = new View('purdy'); 
     $view->records = $records; 
     $this->template->content = $view; 
    } else { 
     $this->auto_render = FALSE; 
     $this->request->headers['Content-Type'] = 'text/xml'; 
     $view = new View('raw'); 
     $view->records = $records; 
     $this->response->body($view->render()); 
    } 
} 

### THE PURDY VIEW ### 
<table> 
    <? 
    foreach ($records as $record) { 
     echo '<tr>'; 
     echo '<td>'.$record->name.'</td>'; 
     echo '<td>'.$record->value.'</td>'; 
     echo '</tr>'; 
    } 
    ?> 
</table> 

### THE RAW VIEW ### 
<?xml version="1.0" encoding="utf-8"?> 
<scores> 
    <? 
    foreach ($records as $record) { 
     echo '<score>'; 
     echo '<name>'.$record->name.'</name>'; 
     echo '<value>'.$record->value.'</value>'; 
     echo '</score>'; 
    } 
    ?> 
</scores>