0

I am building a custom theme based on Magento 1.9 RWD.

How do I manage to hide/close the mini cart and header-account drop down by clicking anywhere outside of those sections ?

EDIT - 1

zhartaunik's answer helped me to resolve the issue. But I am now facing below issue.

If I click the language-switcher its stays open. Now when I click the mini cart and header-account, those drop-downs opens, but also the language-switcher still stays open! I want this one to close directly when another button is clicked? How do I get this done?

  • Hello Meez, your first qustion is answered by zhartaunik and it helped you also. So you should reward him by accepting his answer. If you have further doubts or quiries, feel free to put a new question or contact zhartaunik for more info. Thanks. – Rajeev K Tomy May 12 '15 at 5:50
2

Hope It has no issues...

Add this script to

/app/design/frontend/rwd/default/template/checkout/cart/minicart/items.phtml

<script>
    $j('body').click(function (event)
    {
        element = $j(event.target);
        if(element.parents('.skip-link.skip-cart').length == 1 || element.hasClass('skip-cart'))
        {
            return;
        }
        var parent = $j('.minicart-wrapper').parents('.skip-content');
        var link = parent.siblings('.skip-link');

        if (element.parents('.minicart-wrapper').length == 0) {
            parent.removeClass('skip-active');
            link.removeClass('skip-active');
        }
    });
</script>

upd.1

My cart is closing successfully with that extension:

enter image description here

Maybe you have some javascript errors in console? As you can see - my javascript is simple. If you click outside of block - it gets closed.

  • Ok that looks good. Thanks. And if i click first the language switcher and then the minicart. The language switcher stays open? How do i close this one automatically when clicking another link? – Meez Apr 25 '15 at 19:17
  • I have added ' || element.hasClass('skip-cart')' to if condition. Maybe now everything should work as it should – zhartaunik Apr 25 '15 at 19:47
  • Sorry i am talking about the language-button (English, Dutch etc). This one stays open.. Its not closing when you click a link/button like 'Account' or 'Shopping card'? Do you know how to achieve this? Thanks – Meez Apr 26 '15 at 20:10
  • By which extension did you add these buttons? I can try to install it on my host and help you – zhartaunik Apr 27 '15 at 7:00
  • I made it with this extension. It's really nice and works really great to upgrade the default Magento language switcher. I adjust the code in app/design/frontend/your-package/your-theme/template/page/switch/languages.phtml to make the extension work with Magento. Thanks! – Meez Apr 28 '15 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.