Action specific JS Script just like view scripts
By default, every action has its specific view script like index.phtml
for index
action. However more to this, I also want to have js script specifics to actions as well. like index开发者_高级运维.js
for index
action.
I tried to use $this -> view -> headScript() -> prependScript('myjsfile.js');, but the script is added to top and not at the bottom as I was hoping for. I suppose a helper would do the trick. but i dont know how to create it. or there is a better solution of what i am hoping for.
Even though I appendFile from the action, the files which are appended from the layout file always seems to come at last. Which is not what I want, I want files in the layout file to be loaded first and then the script provided in the action method.
try
$this->view->headScript()->appendFile('myjsfile.js');
instead of prepend!
you can altough define an order for the files:
$this->headScript()->offsetSetFile(1, 'myjsfile1.js')
->offsetSetFile(2, 'myjsfile2.js');
精彩评论