I came across the case where depending on the execution path I may need to invoke an inclusion of .js file from controller. Is there a nice way of doing it? (besides setting some view variable with actual .js include code)?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See the view helper headScript(). I’m just writing this off the top of my head but I think it works like this:
From within a view file:
$this->headScript()->appendFile('filename.js');From within a controller:
$this->view->headScript()->appendFile('filename.js');And then somewhere in your layout you need to echo out your headScript object:
<?=$this->headScript();?>