magento 使用 jquery 与 noconflict [英] magento using jquery with noconflict

查看:32
本文介绍了magento 使用 jquery 与 noconflict的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的 Magento 商店使用 2 个 jquery 脚本.其中一个脚本,一个滑块可以完美运行,而另一个则不起作用.

I'm using 2 jquery scripts for my Magento store. One of those scripts, a slider works perfectly and the other one doesnt work.

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

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 0,
        wrap: 'circular',
        animation: 600,
        scroll: 6,
        initCallback: mycarousel_initCallback
    });

    $('.block_cart_header').hover(function(){
        $('.cart_add_items').fadeIn(700);
    },
    function(){
        $('.cart_add_items').fadeOut(700);
    });


});

jQuery(document).ready(function() {
    jQuery('.dropdown').selectbox();
}); });</script>

当我删除 jQuery.noconflict();两个脚本都有效,但原型脚本无效.

When I remove jQuery.noconflict(); both of the scripts work but the prototype script doesnt work.

这是不起作用的脚本:

jQuery(document).ready(function() {
jQuery('.dropdown').selectbox();}); });</script>

推荐答案

你需要把所有的 $( 替换成 jQuery($.> 进入 jQuery. 中的 jQuery 相关功能和插件.

You need to replace all $( into jQuery( and $. into jQuery. in jQuery related functions and plugins.

例如在您的代码中替换

jQuery('.block_cart_header').hover(function(){
        jQuery('.cart_add_items').fadeIn(700);
    },
    function(){
        jQuery('.cart_add_items').fadeOut(700);
    });

额外信息

您可以更改库文件启动的顺序.在 page.xml 中更改顺序如下

Extra information

You may change the order of library file initiating. In page.xml change order as below

  1. jquery.js
  2. noconflict.js
  3. prototype.js这将避免 IE8 中的错误.

希望能帮到你

这篇关于magento 使用 jquery 与 noconflict的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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