我在 templatete index.php 上添加了 javascript
$doc = JFactory::getDocument();
$doc->addScript($this->baseurl . '/templates/' . $this->template . '/js/jquery.js', 'text/javascript');
并在下面的组件上添加了另一个
$document = JFactory::getDocument();
$document->addScript($this->baseurl . '/templates/' . $this->template . '/js/validation.js');
但组件的 js (validation.js) 总是在 tempelete js(jquery.js) 之前添加
如何在 templatete js(jquery.js) 之后添加组件 js(validation.js)。
如果您正在使用jquery.js
作为项目中的主要 jQuery 库,那么您可以简单地包含jquery.js
在头模块之前index.php
。像下面这样。
<script src="templates/js/jquery.js" type="text/javascript"></script>
<jdoc:include type="head" />
然后在您的组件中您可以简单地使用如下所示的内容。
$document = JFactory::getDocument();
$document->addScript($this->baseurl . '/templates/' . $this->template . '/js/validation.js');
另一个选项是 Addcustom tag ,有助于将脚本添加到文档中。
$document = JFactory::getDocument();
$document->addCustomTag('<script src="'.$this->baseurl . '/templates/' . $this->template . '/js/validation.js" type="text/javascript"></script>');
否则你必须加载组件js
也在index.php
与第二个订单,但这将加载js
所有页面的文件。
希望它有帮助..
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)