2011-01-25 20 views
4

我有一個選擇框,我想用它來Ajax-更新頁面上的其他內容。所以,我已綁定使用JsHelper(jQuery的)的事件處理程序,像這樣:在CakePHP中使用JsHelper獲取selectbox的值

<?php 
echo $this->Form->select('car', $cars); 
$this->Js->get("#car"); 
$this->Js->event('change', $this->Js->request(array(
    'controller' => 'cars', 
    'action'  => 'view', 
    ???, 
    array('async' => true, 'update' => '#car-view', 'evalScripts' => true), 
    true 
)); 
?> 

但我怎麼能得到選擇框的值作爲參數發送給汽車控制器(在「???」在上面的代碼中)?

我可以在JavaScript中做所有事情,但有沒有辦法在蛋糕中做到這一點?

回答

1

說實話,我一直在努力。我找不到任何有效的工具,所以我最終只是選擇了直接的javascript路線。

+0

我一直在試圖弄清楚這一點的年齡太大,仍然沒有來翻過任何有用的東西。 – 2012-03-27 08:21:19

1

我認爲你正在尋找這樣的:

$this->Js->get('#selectbboxid1')->event('change', 
     $this->Js->request(array(
      'action' => 'function'), array(
       /*'before' => 'showLoader();', 
       'success' => 'hideLoader();',*/ 
       'update' => '#selectboxid2', 
       'dataExpression'=>TRUE, 
       'method'=>'POST', 
       'async'=>TRUE, 
       'data' => $js->serializeForm(array('isForm' => TRUE, 'inline' => TRUE)) ))); 
相關問題