How can I integrate Prototype and jQuery with Scriptaculous?

时间:2023-01-27 14:41:42

I have been using jQuery, and I need to use Script.aculo.us and Protoype. I have tried using the jQuery library extending another library. I defined it using the following syntax:

我一直在使用jQuery,我需要使用Script.aculo.us和Protoype。我尝试使用扩展另一个库的jQuery库。我使用以下语法定义它:

jQuery.noConflict();
jQuery(document).ready(function() {
});

My jQuery works properly, and I have divided the three modules. I need to have all three modules on the same page. I know using all three different libraries is not very efficient, but I don't see another way.

我的jQuery工作得很好,我把这三个模块分开了。我需要在同一页面上拥有所有三个模块。我知道使用所有三个不同的库不是很有效,但我没有看到另一种方式。

  • For validation I am using jQuery and Ajax (as an example: validation.js).

    为了验证,我使用的是jQuery和Ajax(例如:validation.js)。

  • The rest of my animation uses Prototype and Script.aculo.us (as an example: animation.js).

    我动画的其余部分使用Prototype和Script.aculo.us(例如:animation.js)。

I have separated the script files. My problem is that now if my animation part works properly, then the Ajax part doesn't work. If the Ajax part is working the validation is not working. I am replacing the code, but I am still unable to integrate.

我已经分离了脚本文件。我的问题是,现在如果我的动画部分正常工作,那么Ajax部分不起作用。如果Ajax部分正在运行,则验证无效。我正在替换代码,但我仍然无法集成。

Questions:

  1. Does jQuery provide a simple way to make this work?

    jQuery是否提供了一种简单的方法来使其工作?

  2. Is there a procedure that Prototype and Script.aculo.us has that should not conflict with jQuery?

    Prototype和Script.aculo.us有一个不应该与jQuery冲突的程序吗?

2 个解决方案

#1


2  

I think the best thing you can do is to switch your AJAX and validation from jQuery to Prototype. That should fix the problems. Prototype has good validation and AJAX too.

我认为你能做的最好的事情就是将你的AJAX和验证从jQuery切换到Prototype。那应该解决问题。 Prototype也有很好的验证和AJAX。

http://prototypejs.org/api/ajax

and for validation just google "prototype validation".

和验证只是谷歌“原型验证”。

You could also switch the animation part to jQuery (it has very nice animation functions).
http://docs.jquery.com/Effects

您还可以将动画部件切换为jQuery(它具有非常好的动画功能)。 http://docs.jquery.com/Effects

I would personally do the latter since I prefer jQuery's non interference with the object.prototype chain.

我个人会做后者,因为我更喜欢jQuery不干扰object.prototype链。

#2


0  

You're better off picking one set of libraries. jQuery and Prototype can both handle the same sort of stuff, and they don't much like to play in the same sandbox.

你最好选择一套图书馆。 jQuery和Prototype都可以处理相同类型的东西,并且它们不太喜欢在同一个沙箱中玩。

#1


2  

I think the best thing you can do is to switch your AJAX and validation from jQuery to Prototype. That should fix the problems. Prototype has good validation and AJAX too.

我认为你能做的最好的事情就是将你的AJAX和验证从jQuery切换到Prototype。那应该解决问题。 Prototype也有很好的验证和AJAX。

http://prototypejs.org/api/ajax

and for validation just google "prototype validation".

和验证只是谷歌“原型验证”。

You could also switch the animation part to jQuery (it has very nice animation functions).
http://docs.jquery.com/Effects

您还可以将动画部件切换为jQuery(它具有非常好的动画功能)。 http://docs.jquery.com/Effects

I would personally do the latter since I prefer jQuery's non interference with the object.prototype chain.

我个人会做后者,因为我更喜欢jQuery不干扰object.prototype链。

#2


0  

You're better off picking one set of libraries. jQuery and Prototype can both handle the same sort of stuff, and they don't much like to play in the same sandbox.

你最好选择一套图书馆。 jQuery和Prototype都可以处理相同类型的东西,并且它们不太喜欢在同一个沙箱中玩。