使用Joomla 2.5,我有一个双实例的jquery在我的一个页面上运行,我想摆脱它。 我尝试使用,
$document->getHeadData();
无济于事。 该数组不包含我需要取消设置的 js 文件。 那么找到 js 文件并卸载它的最佳选择是什么? 它似乎在页面渲染过程的后期加载,然后重新填充头部数据。 我正在使用一个加载了其他扩展的 yoo 主题模板。
如果可能的话,我想避免对模板/扩展文件进行硬编码,因为这会在每个页面上卸载它,而我只想卸载一页。
试试这个,
<?php
//get the array containing all the script declarations
$document = JFactory::getDocument();
$headData = $document->getHeadData();
$scripts = $headData['scripts'];
unset($scripts['/media/system/js/mootools-core.js']);
unset($scripts['/media/system/js/mootools-more.js']);
$headData['scripts'] = $scripts;
$document->setHeadData($headData);
?>
或
<?php unset($this->_scripts['/media/system/js/mootools-core.js']); ?>
然后只需使用 $document->addScript()
添加新的js
文件即可。
希望它的工作..