题
如何在我的ZF路径“public / js / isround.js”中添加我自己的jQuery插件?
- 使用Zend Framework应用而不是手动放置以下内容:
<script> $("#world").isRound('myPlugin'); </script>
.
-
jquery设置工作
$this->jQuery()->setLocalPath('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js') ->enable() ->setUiLocalPath('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js') ->uiEnable() ->addStylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/ui-lightness/jquery-ui.css');
-
文件应用程序/视图/脚本/ index / index.phtml,我有:
_____my js插件在这里申请_____
解决方案
使用视图助手。 zend文档 查看: 示例#2构建自己的帮助程序,没有冲突模式
还有一个关于Viewhelpers和jQuery zendcast
这是一些代码: 在名为mylib的库文件夹中创建一个文件夹。 在它创建一个文件夹视图。 在视图中创建文件夹帮助程序。 在帮助者中创建一个名为的文件:ISRound.php
<?php
class Mylib_Views_Helpers_IsRound {
public function isRound($elem){
echo '<script type="text/javascript">$("'.$elem.'").isRound();</script>';
}
}
.
在indexController.php中的索引中
$this->view->addHelperPath('Mylib/views/helpers', 'Mylib_Views_Helpers');
.
在index.phtml:
<?php $this->isRound('#elem'); ?>
.
希望这有帮助!
其他提示
是你想要的吗?
$this->headScript()->appendFile('/js/isround.js');
. 不隶属于 StackOverflow