简体   繁体   English

Joomla 2.5没有通过文章加载JS脚本?

[英]Joomla 2.5 not loading JS scripts through article?

In Joomla 2.5 I have installed DirectPHP, which I have used extensively in Joomla 1.6 to embed PHP in Joomla articles. 在Joomla 2.5中,我安装了DirectPHP,我在Joomla 1.6中广泛使用了将PHP嵌入到Joomla文章中。 It works very well. 它工作得很好。 I usually just for one include in the article, like this: 我通常只在文章中包含一个,如下所示:

<?php
    include "my_cool_script.php";
?>

Then I make my code in my_cool_script.php . 然后我在my_cool_script.php创建我的代码。 One thing I often do is include more JS or CSS scripts in the page, right through the article, but putting the following lines in my_cool_script.php : 我经常做的一件事是在页面中包含更多JS或CSS脚本,直到文章,但在my_cool_script.phpmy_cool_script.php以下行:

<link rel="stylesheet" type="text/css" media="screen" href="/scripts/css/dark-hive/jquery-ui-1.8.21.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/scripts/css/ui.jqgrid.css" />
<script src="/scripts/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/scripts/js/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<script src="/scripts/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="/scripts/js/jquery.jqGrid.src.js" type="text/javascript"></script>

This has always worked in the past, with Joomla 1.6. Joomla 1.6在过去一直有效。 Now in the Joomla 2.5 install. 现在在Joomla 2.5安装中。 The rest of the PHP and HTML is loading in the article, and there aren't any errors on the page as far as loading the scripts. 本文中正在加载PHP和HTML的其余部分,并且在加载脚本时页面上没有任何错误。 I look at the HTML code and I can see the above lines written to the page, but I cannot access any of the jQuery functions, like the script was not loaded. 我查看HTML代码,我可以看到上面的行写到页面,但我无法访问任何jQuery函数,如脚本未加载。 I get an error when I try to use any jQuery syntax. 当我尝试使用任何jQuery语法时出错。 I know this script was working, because I just moved it from another site, running joomla 1.5 to the new one, 2.5. 我知道这个脚本正在运行,因为我只是将它从另一个站点移动,将joomla 1.5运行到新的2.5。

Does anyone know anything about why the scripts aren't loading? 有没有人知道为什么脚本没有加载?

EDIT 编辑

Well i guess the script was loading, but it didn't like that used the $ symbol. 嗯,我想脚本正在加载,但它不喜欢使用$符号。 I changed them all to jQuery and it works. 我将它们全部更改为jQuery并且它可以工作。

I am not sure exactly why, but perhaps in my installation there is some conflict, and the $ symbol is being recognized as it usually does, signifying that we are dong jQuery. 我不确定为什么,但也许在我的安装中存在一些冲突,并且$符号通常被识别,表示我们是dong jQuery。 So I changed all the $ to jQuery in my PHP scripts and all the jQuery seems to be working now. 所以我在我的PHP脚本中将所有$更改为jQuery ,所有jQuery似乎都在运行。

Mootools (Joomla's javascript default framework until version 2.5) also uses '$', so it's very easy to run into some complications if you're unaware you're running scripts relying on both frameworks side to side. Mootools(Joomla的javascript默认框架直到版本2.5)也使用'$',所以如果你不知道你正在运行依赖于两个框架的脚本,那么很容易遇到一些复杂问题。

Having said that, you could use 'jQuery' instead of '$' and release '$' for everyone else using the jQuery.noConflict(); 话虽如此,您可以使用'jQuery'而不是'$'并使用jQuery.noConflict();为其他人发布'$' jQuery.noConflict(); command. 命令。

Cheers. 干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM