Joomla 331 Uncaught ReferenceError:未定义jQuery

时间:2014-06-18 15:36:59

标签: jquery joomla

我突然开始收到以下错误: 未捕获的ReferenceError:未定义jQuery。

我不是那么流利的PHP所以请善待。 LOL

我的index.php模板的头代码是:

<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/system.css" />
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/general.css" />

<!-- Created by Artisteer v4.2.0.60623 -->


<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width" />

<!--[if lt IE 9]><script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.css" media="screen" />
<!--[if lte IE 7]><link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" /><![endif]-->
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.responsive.css" media="all" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans&amp;subset=latin" />
<link rel="shortcut icon" href="<?php echo $templateUrl; ?>/favicon.ico" type="image/x-icon" />

<script>if ('undefined' != typeof jQuery) document._artxJQueryBackup = jQuery;</script>
<script src="<?php echo $templateUrl; ?>/jquery.js"></script>
<script>jQuery.noConflict();</script>
<script src="<?php echo $templateUrl; ?>/script.js"></script>
<script src="<?php echo $templateUrl; ?>/script.responsive.js"></script>
<script src="<?php echo $templateUrl; ?>/modules.js"></script>
<?php $view->includeInlineScripts() ?>
<script>if (document._artxJQueryBackup) jQuery = document._artxJQueryBackup;</script>

1 个答案:

答案 0 :(得分:5)

这是因为您在<jdoc:include type="head" />之后加载了jQuery。您应该在此行之上加载jQuery甚至更好,请使用以下命令:

JHtml::_('jquery.framework');

所以你最终的代码是:

<head>
<?php JHtml::_('jquery.framework'); ?>

<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width" />
<link rel="shortcut icon" href="<?php echo $templateUrl; ?>/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans&amp;subset=latin" />
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/system.css" />
<link rel="stylesheet" href="<?php echo $document->baseurl; ?>/templates/system/css/general.css" />
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.css" media="screen" />
<link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.responsive.css" media="all" />

<!--[if lt IE 9]>
    <script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--[if lte IE 7]>
    <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" />
<![endif]-->

<jdoc:include type="head" />
<script src="<?php echo $templateUrl; ?>/script.js"></script>
<script src="<?php echo $templateUrl; ?>/script.responsive.js"></script>
<script src="<?php echo $templateUrl; ?>/modules.js"></script>
<?php $view->includeInlineScripts() ?>
<script>if (document._artxJQueryBackup) jQuery = document._artxJQueryBackup;</script>

你可能已经注意到了,我已经交换了一些东西,所以订单更清洁。

另外,我还建议你删除它:

<!--[if lte IE 7]>
    <link rel="stylesheet" href="<?php echo $templateUrl; ?>/css/template.ie7.css" media="screen" />
<![endif]-->

因为Internet Explorer非常陈旧,所以不应该有任何理由支持它。

希望这有帮助

相关问题