Can I include jQuery and AJAX in the sa开发者_开发技巧me file? Would this conflict?
I am attempting to include jQuery with a Magento GO template, but when I upload and include jQuery in the template, the drop down menus/etc. stop working. The links all still work fine, but the dropdown menus, and other similar functionality stop working...
I believe this may be because Magento includes AJAX in the hosted solution on their end..?
The first line of your jQuery code needs to be:
jQuery.noConflict();
The noConflict function takes out a lot of what causes cross-library errors.
No, using jQuery along with another library that uses AJAX does not cause any conflicts.
What can cause a conflict is that the jQuery library uses the $
identifier. If the other code is also using that, they won't work togehter unless you use the noConflict method in jQuery.
Magento includes Prototype by default. It's strongly recommended that you do NOT add jQuery unless it cannot be avoided. Pretty much any functionality that jQuery provides is also available in Prototype/Scriptaculous, it's just not as popular (and/or well marketed) as jQuery.
As the other answers have suggested, you need to put jQuery into noConflict
mode. You will find that you might still encounter other issues, but it's a start.
精彩评论