开发者

jQuery Accordion + Magento problems - Possible conflict?

开发者 https://www.devze.com 2023-04-08 12:14 出处:网络
I\'m using the jQuerytools accordion/tab within a Magento environment and for some reason the script doesn\'t seem to be working.

I'm using the jQuerytools accordion/tab within a Magento environment and for some reason the script doesn't seem to be working.

If you look at the working page below you will see the content and script in a standalone environment working ok.

But as soon as it is dropped in to Magento (Non-working page) the accordion panes don't open and I can't se开发者_Go百科e any obvious errors.

Working Page - http://www.justkitchens.co/sandbox/JustDoors/acrylic-kitchen-doors-chooser.html Non-Working Page - http://www.justkitchens.co/chooser-test/

Can anyone help me out here?

EDIT: I've commented out the jquery-ui.min.js script being called up and things seem to be working... so looks like a conflict there...


Are you running jquery in noConflict mode?

Magento uses prototype so you need to do this.

From http://www.fontis.com.au/blog/magento/using-jquery-magento:

Normally, this would be all you need to do, however because Magento also includes
Prototype, there is a subtlety we need to deal with. jQuery uses $ as shorthand for accessing the jQuery library. But Prototype also uses $ to access itself. This causes a conflict in the global JavaScript namespace of the web browser. Fortunately jQuery provides a solution, the jQuery.noConflict(); function defines a new shorthand for jQuery, such as:

var $j = jQuery.noConflict();

The above code needs to come after the jQuery library code, but before any other JavaScript libraries. You can include the noConflict call at the bottom of the jQuery file you have copied to the js directory. Therefore you need make sure that "action method" line we included in layout/page.xml comes before the code that includes Prototype or any other JavaScript libraries.

An alternative article on it: http://css-tricks.com/2011-using-jquery-in-magneto/

0

精彩评论

暂无评论...
验证码 换一张
取 消