I have created a custom view helper and i’m calling it successfully. Only problem that i’m having is that it seems as though i’m unable to inject code into the headScript by doing the following. Everything else inside my view helper is working perfectly.
$this->view->headScript()->captureStart();
echo '
$(function() {
//js code here
});
';
$this->view->headScript()->captureEnd();
Any help would be appreciated.
Further investigation:
Seems as though this is only happening on view helpers called from my layout. Calling the view helper from inside a view script works. I’m stumped!
More Investigation:
echoing out the headscript like below works. anyone know why that is?
echo $this->view->headScript()->appendFile(filename) // works
echo $this->view->headScript()->appendScript(script) // works
Have you tried to use the
appendScript()method?I mean: