在敏捷工具包中执行多个js答案

时间:2013-08-03 16:22:53

标签: atk4

如何执行多个js?

if($form->isSubmitted()){
    $hashed_user->js()->val("r")->execute();
    $hashed_pass->js()->val("r")->execute();
}

第二个不起作用......

1 个答案:

答案 0 :(得分:4)

这很简单 - 只需将这些链放在js()方法中,将第二个参数作为数组。

if ($form->isSubmitted) {
    $this->js(null, array(
        $this->js()->doSomething('A'),
        $this->js()->doSomething('B'),
        $this->js()->doSomething('C'),
    ))->execute();

    // this line will be never run
}

- > execute()应该只有一个,因为它会停止渲染PHP脚本并回显出对浏览器的JS响应。