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>

1 comment:

Marc Pinnell said...

I put that code at the very bottom of my layout (just before the /body tag). No help. If I click on a parent item, then click the background of the site the parent menu disappears.