CakePHP - JsHelper::event returns null

Go To StackoverFlow.com

0

I am trying to use the JsHelper::event method on my app, using the same code of the CookBook:

$this->Js->get('#element');
$ev = $this->Js->event('click', $this->Js->alert('hey you!'));

I try to run debug($ev), but it returns null. In the controller, I am adding the helper like this:

var $helpers = array('Js' => array('Jquery'));

How do I get the JsHelper::event to work properly?

2012-04-04 18:16
by yrouel


0

By default, the JsHelper buffers those calls, hence the null return. You can return it inline if you want by setting 'buffer' => false in your options.

See the book for more information: http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#javascript-engine-usage

2012-04-04 20:31
by jeremyharris
Ads