I trying to add javascript code to my view so i followed this tutorial and I added this below to my controller:
$scripts = $this->view->inlineScript();
$scripts->appendScript('alert("jfkasd")');
But i there is either no alert pop up nor I find any reference to alert() function in the source code of the page.
Since I don’t know exactly if I write those lines in the action or the view, I also tried this:
<!-- /views/scripts/contracts/generalinfo.phtml -->
<?php $scripts = $this->inlineScript() ?>
<?php $scripts->appendScript('alert("jfkasd")') ?>
but the result is the same as before..
Any idea?
You have to echo out the scripts. Basic idea would be
Or, is set in the controller you would put this in either your view or layout file: