0

如何使用 js helper 在 cakephp 中翻译成功?

$.ajax({
//(...)
success:function (data, textStatus) {
                        $("#city-wrap").html(data);
                        $("#AdCityId").selectbox();
                    },
});
return false; 

我在 cakephp 中试过这个没有成功:

 $this->Js->get('#AdCountryId1')->event('change', 
$this->Js->request(array(
    'controller'=>'cities',
    'action'=>'getByCountry'
    ), array(
    'update'=>'#city-wrap',
    'success'=> '$("#AdCityId").selectbox()';, <= here is what I need !
    'async' => true,
    'method' => 'get',
    'dataExpression'=>true,
    'data'=> $this->Js->serializeForm(array(
        'isForm' => true,
        'inline' => true
        ))
    ))
);

问候

4

2 回答 2

0

实际的ajax调用是否被执行?

如果是; 试试这个,看看是否真的调用了成功回调。

$this->Js->get('#AdCountryId1')->event('change', 
    $this->Js->request(
        array(
            'controller'=>'cities',
            'action'=>'getByCountry'
        ), 
        array(
            'update'=>'#city-wrap',
            'success'=> "alert('Success!'); $('#AdCityId').selectbox();",
            'async' => true,
            'method' => 'get',
            'dataExpression'=>true,
            'data'=> $this->Js->serializeForm(array(
                'isForm' => true,
                'inline' => true
            ))
        )
    )
);

如果你会看到成功!消息,可能有问题$('#AdCityId').selectbox();

于 2012-08-07T14:06:54.040 回答
0

我有同样的问题我想我找到了一个解决方案看看它是否适合你

$this->Js->get('#AdCountryId1')->event('change', 
$this->Js->request(array(
    'controller'=>'cities',
    'action'=>'getByCountry'
    ), array(
    'update'=>'#city-wrap',
    'success'=> '$("#AdCityId").selectbox()';, <= here is what I need !
    'async' => true,
    'method' => 'get',
    'dataExpression'=>true,
    'data'=> $js->serializeForm(array(
        'isForm' => true,
        'inline' => true
        ))
    ))
);

试试这个它会工作

于 2013-01-01T09:36:21.170 回答