admin管理员组文章数量:1387381
I'm new with javascript, so i'm trying to use two jQuery plugins, together they don't work properly. Just if i remove one of two.
How can i resolve this problem ? I could paste both .js files, but that is 2k lines of code, I don't want bother you with so many lines of code.
jQuery.autoplete.js
Greybox plugin AJS.js
Or if you know some plugin that do some functionality, will help too =)
-- UPDATE:
Thank you guys, (i'm not able to add ment in your answers (i really don't know why), some problem with the site.) @Mörre i noted when i remove this line in AJS.js it works (part of it) :
AJS.exportToGlobalScope();
But after that I don't know what to do, sorry guys, I'm new in javascript so many things that you said I don't understand.
@Jim, i don't find any:
$(document).ready(function() { });the replace by jQuery as you said.
I try to replace all '$' by 'jQuery', and still doesn't work.
I'm new with javascript, so i'm trying to use two jQuery plugins, together they don't work properly. Just if i remove one of two.
How can i resolve this problem ? I could paste both .js files, but that is 2k lines of code, I don't want bother you with so many lines of code.
jQuery.autoplete.js
Greybox plugin AJS.js
Or if you know some plugin that do some functionality, will help too =)
-- UPDATE:
Thank you guys, (i'm not able to add ment in your answers (i really don't know why), some problem with the site.) @Mörre i noted when i remove this line in AJS.js it works (part of it) :
AJS.exportToGlobalScope();
But after that I don't know what to do, sorry guys, I'm new in javascript so many things that you said I don't understand.
@Jim, i don't find any:
$(document).ready(function() { });the replace by jQuery as you said.
I try to replace all '$' by 'jQuery', and still doesn't work.
Share Improve this question edited Nov 4, 2014 at 7:25 Chris Martin 30.8k12 gold badges80 silver badges140 bronze badges asked Mar 5, 2011 at 13:00 Valter SilvaValter Silva 16.7k53 gold badges141 silver badges221 bronze badges 1- "They don't work properly" does not adequately describe what is going wrong for you. Are there JavaScript errors in the console when you load the page? Do aspects of the plugins not work? Are there page layout issues? There are many possibilities but you've told us nothing. – Pointy Commented Mar 5, 2011 at 13:06
2 Answers
Reset to default 3Valter,
you may find that there's a collision on the $ alias going on. you'll possibly get it to work if you explicity reference jquery
object using the full jquery alias
i.e rather than:
<script type="text/javascript">
$(document).ready(function() {
});
</script>
try:
<script type="text/javascript">
jQuery(document).ready(function() {
});
</script>
change any $
references to jQuery
in the client code when using the autoplete lib.
just a thought if it's in relation to this'area'
Without checking any further after looking at the code briefly, the AJS code puts everything in a global object AJS at first - but then exports every single property of that object into the global namespace. Bad behavior. The first one is a regular jQuery plugin. Remendation: Don't use AJS, or remove the export to global space (you then just call AJS methods by prefixing them with "AJS.").
本文标签: jqueryConflict with 2 javascript filesStack Overflow
版权声明:本文标题:jquery - Conflict with 2 javascript files - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744551696a2612220.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论