简体   繁体   English

与2个javascript文件冲突

[英]Conflict with 2 javascript files

I'm new with javascript, so i'm trying to use two jQuery plugins, together they don't work properly. 我是javascript的新手,所以我试图使用两个jQuery插件,它们一起工作不正常。 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. 我可以粘贴两个.js文件,但这是2k行代码,我不想用这么多行代码打扰你。

Or if you know some plugin that do some functionality, will help too =) 或者,如果你知道某些功能的插件,也会有帮助=)

-- UPDATE: - 更新:

Thank you guys, (i'm not able to add comment 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) : 谢谢你们,(我无法在你的答案中添加评论(我真的不知道为什么),这个网站存在一些问题。)@Mörre我注意到当我在AJS.js中删除这一行时它有效(部分它):

AJS.exportToGlobalScope(); 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. 但在那之后,我不知道该怎么做,对不起,伙计们,我是javascript的新手,你说的很多东西,我不明白。

@Jim, i don't find any: @Jim,我找不到:

$(document).ready(function() { }); $(document).ready(function(){});

the replace by jQuery as you said. 正如你所说,jQuery的替换。

I try to replace all '$' by 'jQuery', and still doesn't work. 我尝试用'jQuery'替换所有'$',但仍然不起作用。

Valter, 瓦尔特,

you may find that there's a collision on the $ alias going on. 你可能会发现$ alias正在发生碰撞。 you'll possibly get it to work if you explicity reference jquery object using the full jquery alias ie rather than: 如果你使用完整的jquery alias明确引用jquery对象,那么你可能会让它工作,而不是:

<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 autocomplete lib. 使用自动完成库时,在客户端代码中更改对jQuery任何$引用。

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. 在简单地查看代码之后没有进一步检查,AJS代码首先将所有内容放入全局对象AJS中 - 但随后将该对象的每个属性导出到全局命名空间中。 Bad behavior. 不良行为。 The first one is a regular jQuery plugin. 第一个是常规的jQuery插件。 Recommendation: Don't use AJS, or remove the export to global space (you then just call AJS methods by prefixing them with "AJS."). 建议:不要使用AJS,或者删除导出到全局空间(然后通过在前面加上“AJS”来调用AJS方法)。

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

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