views:

45

answers:

5

HI All,

I read all the related post but i think i am missing something.

My page structure is -

1.load Motools library in Joomla. code is JHTML::_('behavior.tooltip');
JHTML::_('behavior.mootools'); JHTML::_('behavior.formvalidation');

2 Then load the Jquery library code is <script language="javascript" src="<?=$this->baseurl;?>/includes/js/jquery/jquery-1.3.2.js"></script> <script type="text/javascript" src="<?=$this->baseurl;?>/includes/js/jquery/customjsfile.js"></script>

3.then there are few JS function which uses Jquery Functionalities code is function abc() {//..stuffs uses jquery} function xyz() {//..another function which uses jquery}

4 load body of the page

5 At the end again few lines of JS code . Which again use Jquery code is
<script language="javascript"> $("#dialog").html(newHTML); </script>

This is how my page is. Now I am getting the Conflict errors in Motools & Jquery.

How Do I Resolve It.

Please HELP!

+1  A: 

Please see:

Using JQuery with other libraries.

Sarfraz
A: 

See this page. It seems to be answered there

http://groups.google.com/group/jquery-en/browse_thread/thread/3dabd31a8ab60505?pli=1

Aykut
+1  A: 

jQuery.noConflict(), this is what you need.

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

source: http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Balon
A: 

use jQuery instead of $ and

give

jQuery.noConflict();

jQuery.noConflict

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict():

rahul
Thanks a Lot!It Works!
I would Like to share thing here - the for-in loop returns some strange o/p.But I managed to overcome it by first taking array.length in a variable then use the for loop to iterate over an array.
http://stackoverflow.com/questions/2040042/javascript-array-iteration-using-for-in-with-mootools-included