如何解决javascript文件冲突? [英] How to resolve javascript files conflict?

查看:106
本文介绍了如何解决javascript文件冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主页上使用了以下两个JS:-

I am using two JS below in my master page :-

<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>

我的问题是,当我添加下面的JS文件"1.10.3"时,我的回发请求之一发送了两次.

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"时,多个回发问题得以解决.这样做,还有另一个javascript错误:-

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 :-

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

要解决该错误,我必须同时包含两个JS文件.

And to resolve that error i have to include both the JS files.

有人可以帮我吗?我正在使用ASP.NET MVC4.

Can anyone help me out on this ? I am working on ASP.NET MVC4.

推荐答案

依赖于库(包括它一次以上)可能会产生不良影响,因为JS的功能可能会发生冲突.为避免这种情况,请将此代码添加到您的JavaScript部分.

Depending on the library, including it more than once could have undesired effects, because the functionality of JS may be conflicting. To avoid this add this code to your JavaScript Part.

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

有关 noConflict 的更多信息: 单击此处>

For More info about noConflict : Click Here

这篇关于如何解决javascript文件冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆