How write JavaScript with Zend Framework and netbeans?

五迷三道 提交于 2019-12-06 12:03:33

You can extend HeadScript, this is simplest solution:

class My_View_Helper_HeadScript extends Zend_View_Helper_HeadScript
{
    public function captureEnd()
    {
        $content = ob_get_contents();
        ob_clean();
        echo strip_tags($content, 'script');

        parent::captureEnd();
    }
}

Specify helper path:

resources.view.helperPath.My_View_Helper = "My/View/Helper"

Usage:

<?php $this->headScript()->captureStart();?>
    <script>
      alert(1);
    </script>  
<?php $this->headScript()->captureEnd(); ?>

Write your js in external JS files.

It will allow for better separation, better caching, better aggregation, better highlighting, etc.

Here are some links that may help you:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!