Magento: 解决 Bootstrap 3 与prototype并用的时候, 下拉菜单消失的问题 Bootstrap 3 dropdown menu dis...

本文介绍了两种解决方法,当Magento使用Prototype.js与Bootstrap 3并存时,如何避免下拉菜单消失的问题。方法一是替换友好的prototype.js文件,方法二是不修改源文件,通过额外的代码实现兼容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

方法一 :  使用友善的文件

 

 

EASY FIX:

 

Just replace Magento’s prototype.js file with this bootstrap friendly one:

 

https://raw.github.com/zikula/core/079df47e7c1f536a0d9eea2993ae19768e1f0554/src/javascript/ajax/original_uncompressed/prototype.js

 

 

You can see the changes made in the prototype.js file to fix the bootstrap issue here:

 

https://github.com/zikula/core/commit/079df47e7c1f536a0d9eea2993ae19768e1f0554

 

NOTE: JQuery must be include in your magento skin before prototype.js.. Example:

 

Download 下载 prototype-friendly.js

 

 

 

 

方法二 : 不修改任何源文件

 

I’ve also used code from here: http://kk-medienreich.at/techblog/magento-bootstrap-integration-mit-prototype-framework but without a need to modify any source. Just put code below somewhere after prototype and jquery includes:

(function() {
    var isBootstrapEvent = false;
    if (window.jQuery) {
        var all = jQuery('*');
        jQuery.each(['hide.bs.dropdown', 
            'hide.bs.collapse', 
            'hide.bs.modal', 
            'hide.bs.tooltip',
            'hide.bs.popover'], function(index, eventName) {
            all.on(eventName, function( event ) {
                isBootstrapEvent = true;
            });
        });
    }
    var originalHide = Element.hide;
    Element.addMethods({
        hide: function(element) {
            if(isBootstrapEvent) {
                isBootstrapEvent = false;
                return element;
            }
            return originalHide(element);
        }
    });
})();

 

 

原文: http://stackoverflow.com/questions/19139063/twitter-bootstrap-3-dropdown-menu-disappears-when-used-with-prototype-js

转自: Magento: 解决 Bootstrap 3 与prototype并用的时候, 下拉菜单消失的问题 Bootstrap 3 dropdown menu disappears when used with prototype.js

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值