旧版本与新版本的 jquery 冲突 [英] Older version conflicting with newer version of jquery

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

问题描述

我遇到了 jquery 插件的一个主要问题.我有一些用 jquery 1.7.1 编写的代码,现在我开始使用 bootstrap 并且需要 1.9.1 jquery 插件或更高版本.

I am stuck in a major issue with jquery plugins. I have some code written with jquery 1.7.1, now I started using bootstrap and that need 1.9.1 jquery plugin or higher.

包含此版本后https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js",我以前的功能停止工作.然后我使用了两个版本,但再次没有运气.

After including this version "https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js ", my previous functionality stopped working. Then I used both versions but no luck again.

我不想重写我以前的代码以使其与新版本兼容.请提供解决方案

I don't want to rewrite my previous code to make it compatible with new version. Please provide solution

我收到很多错误,例如:未捕获的 TypeError: that.errorDialog.dialog is not a function, .live is not a function,.dialog is not defined , null 错误.我的代码在使用 jQuery 1.7.1 时出现错误

I am getting many errors like: Uncaught TypeError: that.errorDialog.dialog is not a function, .live is not a function,.dialog is not defined , null errors. I am getting errors with my code that is working fine with jQuery 1.7.1

如何解决这个问题,请帮忙.

How do I fix this please help.

谢谢!迪皮卡

推荐答案

您可以尝试仅加载较新版本的 jQuery,然后加载 jquery-migrate,这将恢复一些旧功能.但是,在不知道您的应用需要哪些特定功能的情况下,我无法确定这是否能解决问题.

You can try loading just the newer version of jQuery then loading jquery-migrate which will restore some old functionality. However, without knowing what specific features your app needs, I can't be sure that this will solve the problem.

https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/1.2.1/jquery-migrate.min.js

不过,理想情况下,您应该真正识别出依赖于旧版本 jQuery 的代码,并更新它们以使用最新版本.归根结底,对 jQuery 的更改是有原因的.几乎可以肯定,使用新的实现会更好.

Ideally though, you should really identify the code that relies on older versions of jQuery and update them to work with the newest version. At the end of the day, the changes to jQuery were made for a reason. And you're almost certainly better off with the new implementations.

如果您明智地决定更新代码,jQuery Core 1.9 升级指南可能会是一个很好的起点

If you smartly decide to update your code, the jQuery Core 1.9 Upgrade Guide would likely be a good place to start

这篇关于旧版本与新版本的 jquery 冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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