views:

642

answers:

4

I have a lot of jquery code and a little .js script that use prototype

The problem is when i try to call the $$ method in prototype i got the error : $$ is not define

So i like to know the long hand method to get the $$ work

$$('table.'+triggerClass).each(function(t){

is there a way to force that part of the code to use prototype, as it can be done in jquery jQuery.noConflict();

+1  A: 

I'm not sure if there is or isn't a long hand version of $$() for prototype. However, my advice to you is to not use both jQuery and Prototype. I say this for a couple of reasons:

  1. jQuery and Prototype are both rather large libraries which means a big download for your users
  2. jQuery and Prototype have a lot of overlap in features and there are going to be issues with conflicts like you're having now.

I would advise you to rewrite the little js script that's using prototype to use jQuery. (Not that I am recommending one over the other, just given your circumstances, that's what I'd do)

dustyburwell
A: 

As another answer said, try not to use both. Prototype is great for light stuff, jquery for more complicated things.

That being said, you an remap jQuery to get rid of conflicts:

jQuery.noConflict();

and then just assign the jQuery object to a new variable. See here.

patricksweeney
A: 

Absolutely not the kind of answer i am looking for...

last chanche for those jquery litterate out there...

how can i write that in jquery : $$('table.'+triggerClass).each(function(t){

marc-andre menard
A: 

$$() is a prototype function, so if you are trying to leave the code "as-is" you won't be able to get it to work *. If you can change your code (and put JQuery in no conflict mode):

JQuery('table.'+ triggerClass).each(function(t){})

But again, if you have not triggered no conflict mode there are no guarantees which library will serve $().

* I guess in theory, if you really want to leave the reservation, you could map $$() to JQuery() at the risk of breaking things in your prototype code.

Rob