PHP Magento Tips

Hide Mini-Cart and Header-Account Dropdown by Clicking Outside in Magento

Rate this posting:
{[['']]}

sometimes, It is really very annoying that when you click on header mini-cart window and header-account drop down it open very nicely. But when you click on outside of those section it will not close, as you expect.

To close that window you have to click again on those section, Which is sometimes very annoying in Magento.

To solve this Problem add below code.

1. For Header Mini-Cart Window:

add below code at the end of the file at 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> 

2. For Header Account Dropdown:

add below code at the end of the file at app/design/frontend/rwd/default/template/page/template/links.phtml

First add menulinks class besides links class to catch Jquery class very easily and accurately.

<div class="links menulinks"> 


<script>



    $j('body').click(function (event)

    {

        element = $j(event.target);

        if(element.parents('.skip-link.skip-account').length == 1 || element.hasClass('skip-account'))

        {

            return;

        }

        

        var parent = $j('.links.menulinks').parents('.skip-content');

        var link = $j('.skip-link.skip-account');



        if (element.parents('.links.menulinks').length == 0) {

            parent.removeClass('skip-active');

            link.removeClass('skip-active');

        }

    });

</script>
Tag : Magento
1 Comments On "Hide Mini-Cart and Header-Account Dropdown by Clicking Outside in Magento"

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Typo3, kindly contact us http://www.maxmunus.com/contact
MaxMunus Offer World Class Virtual Instructor led training on Typo3. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us:
Name : Arunkumar U
Email : arun@maxmunus.com
Skype id: training_maxmunus
Contact No.-+91-9738507310
Company Website –http://www.maxmunus.com


Back To Top