一些joomla模块不能与我的自定义模板中的不同jquery版本冲突,如何解决?

时间:2014-03-18 15:07:15

标签: jquery joomla joomla-extensions joomla3.0 joomla-template

我用zurb基础框架设计了joomla 3自定义模板,我认为由于jquery冲突,一些模块正在使用最新版本  即使使用jquery noconflict代码,甚至灯箱也不能正常工作。

这是我的自定义模板index.php数据

?php /**  * @copyright  Copyright (C) 2013 Enter Infolabs - All Rights Reserved. **/
defined( '_JEXEC' ) or die( 'Restricted access' ); 
define( 'YOURBASEPATH', dirname(__FILE__) );

JHtml::_('behavior.framework', true);
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$doc->addScript('templates/' .$this->template. '/js/vendor/jquery.js');

$rightcolgrid  = "3";
?>
<!doctype html>
<html class="no-js" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<jdoc:include type="head" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="icon" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/images/favicon.ico" type="image/png">
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css"/>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/foundation.css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" />

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/style.css" type="text/css"/>
<link href='http://fonts.googleapis.com/css?family=Bubbler+One|Maven+Pro' 

rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/foundation-icons.css" />  
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
baseurl?&gt; / templates / template?&gt; /js/jquery-noconflict.js“&gt;
    <!--

      [if IE]><link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/ie.css" media="screen, projection" /><![endif]-->  

    </head>

    <body>

-------------------
----------------
-----------------

<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/foundation/foundation.topbar.js"></script>


    <script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/foundation.min.js"></script>    

<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/vendor/jquery.js"></script>
baseurl?&gt; / templates / template?&gt; /js/jquery-noconflict.js“&gt;
    <script>
      $(document).foundation();
    </script>
</body>
</html>

可以解决问题吗。

1 个答案:

答案 0 :(得分:0)

除了确保你只加载一次jQuery(如@Lodder指出)你有一个noConflict()调用,它会取消分配$的简写。这将成为

$(document).foundation()

失败。你应该用

替换它

jQuery(document).foundation()

你看过siegeengine的Joomla基金会港口吗?它可以为你节省一些麻烦;虽然它与noConflict存在同样的问题,并使用简写$调用基础,但它可能会有所帮助。

另外,为什么不从CDN加载jQuery?