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.
All of the above is giving tons of errors for me and $this->view->headScript() is at all about Zend Framework 1. This works for me:
in your controller before controller's class definition add:
and then you may use something like this in your controller (sure you may use it in any action, not only in the constructor):
and then you should add this to your layout: