2

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

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

  • The rest of my animation uses Prototype and Script.aculo.us (as an example: 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.

Questions:

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

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

Community
  • 1
  • 1
venkatachalam
  • 102,353
  • 31
  • 72
  • 77
  • I'd *strongly* suggest porting everything to just one platform - it'll be more efficient and neat. If not, you'll get terribly busy trying to maintain everything 2 months from now. – Seb Mar 27 '09 at 13:43
  • Here's an easier answer (not mine - can't take credit) http://stackoverflow.com/questions/112721/combining-scriptaculous-and-jquery-in-a-rails-application –  May 07 '10 at 08:18

2 Answers2

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.

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

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

Pim Jager
  • 31,965
  • 17
  • 72
  • 98
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.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368