Using ICEfaces with jQuery Library

ICEfaces is based on Prototype JavaScript-Library, but what when you want to use jQuery in your project too? - The trick is to define separate namespaces for each library, to prevent them from a clash.

The code snipped below shows how to do that:

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

For more details go to http://docs.jquery.com/Using_jQuery_with_Other_Libraries .

0 Kommentare:

Post a Comment