I want to split a unique javascript file to get a file by action. On my controllers I use jQuery()->addJavascriptFile() to call js files :
class DemandesController extends Zend_Controller_Action
{
public function init()
{
$this->view->jQuery()->addJavascriptFile('public/js/' . $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName() . '.js');
}
}
In my public/js folder I got a folder by controller and a js file by action... It works well only with the indexAction, for all of the others the name of the controller is inserted into the URI : With indexAction : http://192.168.78.208/demande_absence/public/js/demandes/index.js With any other : http://192.168.78.208/demande_absence/demandes/public/js/demandes/nouvelle.js
What I've done wrong ?
Try:
$this->view->jQuery()->addJavascriptFile('/public/js/' . $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName() . '.js');
And i think you also have to use something like the baseurl view helper to build a correct url.