user1195246
user1195246

Reputation: 31

Convert jQuery code to mootools 1.11

I use a slideshow which needs mootools 1.11 and my other code needs jQuery. Unfortunately as soon as I call the jquery library the slideshow is crashing.

Can I convert this little jquery code in to moo tools or pure javascript? How would the mootools code look like?

jQuery(document).ready(function(jQuery) {
    jQuery('.rgstitle, .rgsdescription').click(function(event) {
        window.open(jQuery('#rgslideshow-4574 a img:visible').parent().attr('href'), '_self');    
        return false;
    });
});

Thanks a lot!

Upvotes: 1

Views: 543

Answers (3)

prade3p
prade3p

Reputation: 3

Its better to check, Avoiding Conflicts with Other Libraries article from Jquery team. I got the same problem and Solved jQuery slider and mootool news ticker :D

Upvotes: 0

tusar
tusar

Reputation: 3424

Leave the '$' for your mootools based code as it is. And Use 'jQueryDollar' for your jQuery codes. After adding the jquery library, use this :

<script src="jquery.js"></script>
<script>
var jQueryDollar = jQuery.noConflict();
// Do something with 'jQueryDollar'
jQueryDollar(document).ready(function(jQueryDollar) {
    jQueryDollar('.rgstitle, .rgsdescription').click(function(event) {
        window.open(jQueryDollar('#rgslideshow-4574 a img:visible').parent().attr('href'), '_self');    
        return false;
    });
});
</script>

Now add mootools libraries just beneath:

 <script src="mootools.js"></script>
 <script>
     //'$' is now free for mootools
 </script>

Upvotes: 1

charlietfl
charlietfl

Reputation: 171679

Here's a simple fix if you want the 2 libraries to work toghether. Put the following right after jQuery.js script tag

<script type="text/javascript">
 jQuery.noConflict();
</script>

Upvotes: 0

Related Questions