Search code examples
jqueryprototypejs

Prototype and jQuery interference


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();


Solution

  • $$() 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.