I need to add jQuery and other javascript files to my Zend Framework project. I am trying to do it with an Action controller:-
public function userinfoAction()
{
$this->view->headScript()->appendFile($basePath .'/js/validate_jquary.js');
$this->headScript()->appendFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
return new ViewModel();
}
But it is not working.
a good way for that is to use the below code in your controller action lets say u want to include the paginator.js
Here is how you can use view helpers from within a controller in ZF2 to solve your problem:
It is OK with this code in the view. But I don't know is this correct method.
you can try this. its works fine for me
//write these lines in your SampleController
// write following method in controller
Probably the easiest way to use view helpers from within a controller in ZF2 is via the renderer object:
You aren't using the view to add jquery: