Javascript 如何使用cakephp 2.2 jshelper调用其他jshelper函数?
我有以下代码:Javascript 如何使用cakephp 2.2 jshelper调用其他jshelper函数?,javascript,cakephp,cakephp-2.0,Javascript,Cakephp,Cakephp 2.0,我有以下代码: $this->Js->get('#get_meters_today')->event('click', $this->Js->request( array('action' => 'getMetersToday'), array('async' => true, 'update' => '#meters_today') ) ); $this->Html->scriptBl
$this->Js->get('#get_meters_today')->event('click',
$this->Js->request(
array('action' => 'getMetersToday'),
array('async' => true, 'update' => '#meters_today')
)
);
$this->Html->scriptBlock(
$this->Js->domReady(
$this->Js->request(
array('action' => 'getMetersToday'),
array('async' => true, 'update' => '#meters_today')
)
), array('inline' => false)
);
我想做的是让Js->request
编写一次,并由click
方法和domReady
方法引用。我该怎么做
感谢IMO,手工编写jQuery脚本要容易得多,而且只使用JsHelper将它们添加到缓冲区。通过这种方式,您可以更好地控制Javascript,并且更容易调试。我还认为,使用JsHelper是一种可怕的做法,这通常会使事情变得更加困难。