Showing posts with label Dropdown Menu hide on click magento with bootstrap. Show all posts
Showing posts with label Dropdown Menu hide on click magento with bootstrap. Show all posts

Thursday, 23 April 2015

Dropdown Menu disappears on click magento


Dropdown Menu disappears on click magento

Just put below code somewhere after jquery library includes

<script type="text/javascript">
(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);
        }
    });
})();
</script>