Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically include .js files from Zend_Controller_Action?

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)?

like image 943
xelurg Avatar asked Mar 01 '23 04:03

xelurg


1 Answers

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();?>

like image 51
smack0007 Avatar answered Mar 11 '23 07:03

smack0007