jQuery UI和Prototype冲突 [英] jQuery UI and Prototype conflict

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

问题描述

我在Perl的网站上添加了一个新表单(不是我的选择)。有很多html自动生成表单来创建一致的外观。我的问题在于遗产在整个页面中使用原型进行各种操作(包括加载)。但是我想使用jQuery,主要是来自jQuery UI的日期选择器。我可以通过使用jQuery.noConflict();来避免冲突。但是我仍然得到一个错误,因为jQuery日期选择器javascript中有一行代码。

I am adding a new form to our website in Perl (wasn't my choice). There is a lot of html generate automatically for the forms to create the consistant look. My problem comes in where the legacies use prototype for various things throughout the page (including on load). However i want to use jQuery and mainly the date picker from jQuery UI. I can avoid conflicts by using jQuery.noConflict();. But i still get an error becuase of a line of code in the jQuery date picker javascript.

inst.dpDiv.zIndex($(input).zIndex()+1);

看看它是如何仍然包含$符号,原型试图处理但不能。有没有人对我有任何解决方案?我正在使用jQuery 1.5和jQuery UI 1.8.6。

See how it still contains the $ symbol, which prototype tries to handle but can't. Does anyone have any solutions for me? I am using jQuery 1.5 and jQuery UI 1.8.6.

总结:我无法删除prototype.js,我更喜欢使用jQuery UI datepicker和jQuery UI datepicker不处理jQuery.noConflict()。

In summary: I can't remove prototype.js, I would prefer to use jQuery UI datepicker and jQuery UI datepicker doesn't handle jQuery.noConflict().

谢谢

编辑
只有当我尝试点击按钮显示日期选择器时才会发生这种情况。
来自firebug:

EDIT This only happens when i try to click on the button to show the date picker. From firebug:

$(input).zIndex is not a function
inst.dpDiv.zIndex($(input).zIndex()+1);
datepicker.js (line 651)

编辑编辑
更新到jQuery UI 1.8.9不会改变问题。

EDIT EDIT Updating to jQuery UI 1.8.9 doesn't change the problem.

编辑编辑编辑
发生此问题时单击按钮以显示日期选择器。所以在加载时,datepicker设置得很好。更改脚本的顺序不起作用,以下代码的任何变体也不起作用。

EDIT EDIT EDIT This problem occurs when clicking the button to show the date picker. So on load the datepicker is set up fine. Changing the order of the scripts doesn't work, and any sort of variation of the following code doesn't work either.

(function($) { 
  $(function() {
    // more code using $ as alias to jQuery
  });
})(jQuery);


推荐答案

感谢所有回复。我最终无法弄清楚如何解决冲突。所以我从表单中删除了jQuery UI datepicker。再次感谢。

Thanks for all the responses. I couldn't end up figuring out how to fix the conflict. So i removed the jQuery UI datepicker from the form. Thanks again.

这篇关于jQuery UI和Prototype冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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