2014-06-18 50 views
2

我突然開始收到以下錯誤: 未捕獲的ReferenceError:沒有定義jQuery。Joomla 331 Uncaught 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> 

回答

4

這是因爲你<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是非常老不應該有任何理由,你爲什麼必須支持它。

希望這會有所幫助

+0

謝謝Lodder !! 我把這個網站傾倒在我的腿上,我正在學習。 – user3753135

+0

@ user3753135 - 不客氣。如果這解決了您的問題,請點擊勾號圖標接受答案 – Lodder

相關問題