简体   繁体   English

如何解决javascript文件冲突?

[英]How to resolve javascript files conflict?

I am using two JS below in my master page :- 我在主页上使用以下两个JS:-

<script type="text/javascript" src="~/Scripts/jquery-1.7.2.min.js"></script>
<script Src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"> </ script>

My problem is when I add the below JS file "1.10.3", one of my post back request sending two times. 我的问题是,当我添加下面的JS文件“ 1.10.3”时,我的回发请求之一发送了两次。

But when I commented this JS "1.10.3" the multiple post back problem is resolve.And doing this,there is another javascript error is :- 但是当我评论此JS“ 1.10.3”时,多个回发问题得以解决。并且这样做,还有另一个JavaScript错误:-

"typeerror $(...).draggable is not a function"

And to resolve that error i have to include both the JS files. 为了解决该错误,我必须同时包含两个JS文件。

Can anyone help me out on this ? 有人可以帮我吗? I am working on ASP.NET MVC4. 我正在使用ASP.NET MVC4。

Depending on the library, including it more than once could have undesired effects, because the functionality of JS may be conflicting. 取决于库,不止一次包含它可能会产生不良影响,因为JS的功能可能会发生冲突。 To avoid this add this code to your JavaScript Part. 为避免这种情况,请将此代码添加到您的JavaScript部分。

<script>
    ...
    ...
    $.noConflict();
</script>

For More info about noConflict : Click Here 有关noConflict更多信息: 单击此处

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

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