我有一个像这样的js辅助方法:
$this->Js->get('#colorRB' . $key)->event('change', $this->Js->request(array(
'controller' => 'designer',
'action' => 'setParameters', $colorHex['id'], $colorHex['hex_code'], $cNr, False
), array(
'update' => '#testDiv',
'async' => true,
'method' => 'post',
'dataExpression' => true
))
);
是否可以调用javascript方法 - >发生“更新”时, reloadJs()?或者如何重建方法来做到这一点?我只对调用动作“setParameters”感兴趣,而不是它返回的任何内容。之后我需要调用javascript,这需要在完成后取决于动作的作用。
答案 0 :(得分:1)
您可以在回调中运行JavaScript,如request()
方法中所定义。 'update'键只是一种自动更新div的便捷方式,它不做任何事情。在请求成功后运行JS,例如:
$this->Js->get('#colorRB' . $key)->event('change', $this->Js->request(array(
'controller' => 'designer',
'action' => 'setParameters', $colorHex['id'], $colorHex['hex_code'], $cNr, False
), array(
'success' => 'reloadJs()',
'async' => true,
'method' => 'post',
'dataExpression' => true
))
);