0

if i have

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js" type="text/javascript"></script>

both of these in my header my jquery menu does not work. i have searched google and it keeps telling me about this

<script>
     jQuery.noConflict();
     
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });
     
     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>

for the life of me i cant work this out. can anybody explain this in layman terms. i beleive it is because they use the char set but i just dont understand how i can use them both together

many thanks

kard

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by kardklub
0

Basically there is a conflict because both jQuery and prototype use "$" as their control character. To make jQuery work with other frameworks you should use

jQuery.noConflict();

To force jQuery to release the "$" and so you can either assign a new variable or just use jQuery (which is simpler). For more detailed info check out this link: http://docs.jquery.com/Using_jQuery_with_Other_Libraries The example from that article is here:

<html>
 <head>
   <script src="prototype.js"></script>
   <script src="jquery.js"></script>
   <script>
     jQuery.noConflict();
     
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("div").hide();
     });
     
     // Use Prototype with $(...), etc.
     $('someid').hide();
   </script>
 </head>
 <body></body>
 </html>

So anywhere you want to use a prototype function you reference with $ and anywhere you want to do jQuery you use the word jQuery.

0

Thanks for your reply. So do i change all the js files with JQuery instead of $ 99% of them i have just taken from the net and have not written as i am hopeless as js.

kardklub

0

Is there something specific that you are using prototype for? Chances are there is a jQuery plugin that will do the same and then your problem would be solved. Not certain what to do about external jQuery beyond that as I just recently ran across this noConflict solution on a forum recently (I generally just use stright JS or js with a bit of jQuery).

0

your probably right. its a validation form but ill look for a jquery validation. seems like to much hard work ;)

kard

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.