Wednesday, February 1, 2012

Software project: JS feed for joomla - Joomla with jQuery

If you try to use jQuery with Joomla, you will see that it do not work, this is because “mootools.js” that Joomla uses, is conflicting with “jQuery.js”. I came across the same problem in my “JS feed for Joomla” project. Both of them uses same operator ‘$’.


First, make sure that all code work, other than jQuery. So just, comment all codes in your working JS and only write an alert there. Also check if you jQuery library is working (just do it, do not think this is silly). You can do that by using it with a small html. Moreover, in my case it did not work until I put the <script> in last. (So put all you script in the end, like below)

If everything is right, do following. Here we use jQuery.noConflict(); to remove any conflict you have with “mootools.js”. There are several ways. I used the fourth one, which worked for me. All together, there are five ways of doing this. Each example shows a different way. In addition, mind you that I only used the fourth way, it works. Nevertheless, I am sure none of them are wrong, only thing as I have not used them I cannot be sure about them.
If you use 4th method you get the complete separation. After you, create the new variable by, clip_image008
You can use that ‘j’ instead of ‘$’ and you are free to do anything. Use ‘$’ for “mootools.js”

No comments:

Post a Comment