Magento中的jquery/prototype冲突 [英] jquery/prototype conflicts in Magento

查看:70
本文介绍了Magento中的jquery/prototype冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一家基于Themeforest的Acumen主题的Magento商店.

This is a Magento store based on the Acumen theme from Themeforest.

看似出乎意料的是,jQuery东西现在不起作用. Acumen通过magento静态块加载了jquery,但没有一个被触及.

Seemingly out of the blue, jquery stuff is now not working. Acumen has jquery loading through a magento static block and none of that has been touched.

昨天,我正在努力添加jquery.clearfield.js插件,以将该功能添加到我们的表单中.我没有修改核心文件.我通过另一个静态块加载了clearfield插件,并将该静态块添加到了我们的联系CMS"页面.

Yesterday I was working on adding the jquery.clearfield.js plugin to add that functionality to our forms. I wasn't modifying core files. I loaded the clearfield plugin through another static block and added that static block to our contact CMS page.

当时我已登录,并且正在自动填充名称/电子邮件的登录值,有时我以客户身份退出,以在未登录时测试字段值.

I was logged in at the time and was getting the logged in values for name/email populating automatically, and at some point I logged out as a customer to test the field values when not logged in.

由于jquery冲突,我无法登录.我遍历了代码,似乎找不到导致此问题的更改,并且我没有修改任何核心文件或主题文件.

I was unable to login because of the jquery conflicts. I've gone through the code, I can't seem to find anything that's changed that would be causing this, and I hadn't modified any core or theme files.

如果在任何页面上查看source/inspect元素,都会看到原型和jquery错误消息.

If you view source/inspect element on any of the pages, you'll see the prototype and jquery error messages.

任何想法/见识都会有所帮助.

Any thoughts/insight would be helpful.

谢谢.

推荐答案

如果要在您的local.xml中包含jquery并且没有冲突代码,请使用:

If you want to include the jquery and no conflict code in your local.xml then use:

<default>
    <reference name="head">
        <block type="core/text" name="google.cdn.jquery">
            <action method="setText">
                <text><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript">jQuery.noConflict();</script>]]>
                </text>
            </action>
        </block>
    </reference>
</default>

干杯!

修订2:您可能需要编辑page.xml并在其中插入jquery.js和noConflict,因为page.xml在local.xml之前加载.或者,您可以使用local.xml删除所有以前的Prototype js调用,然后重新添加它们.我发现编辑page.xml更加容易.

Revision 2: You will probably want to edit the page.xml and insert the jquery.js and noConflict in there, as page.xml is loaded before local.xml. Or, you can use local.xml to remove all of the previous Prototype js calls, then re-add them. I found editing page.xml to be easier.

此外,我在让Action setText适用于"var jQuery = jQuery.noConflict();"时遇到了麻烦,因此我自己创建了一个单独的js文件.不太好,但是它是在加载主要jQuery js文件之后(以及在Prototype之前)加载的

Also, I had trouble getting Action setText to work for the "var jQuery = jQuery.noConflict();", so I created a separate js file with that line by itself. Not great, but it is loaded right after the main jQuery js file is loaded (and before Prototype)

这篇关于Magento中的jquery/prototype冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆