Your Time:
Our Time:
← Back to discussions

Hide sub-menu after clicking sub-menu item

Need help with a different issue? Search the forums or open a new ticket.
Open a support ticket

This topic has 1 reply, 2 voices, and was last updated 11 years, 9 months ago by Wajid Khan.

  • 2014-11-28 at 7:52 pm
    Support Expired
    #6055
    alaahammoudeh
    Participant
    • Topics: 7
    • Replies: 16
    • Total posts: 23
    • Post count: 24

    Hi MAWK,

    I am trying to hide a superfish sub-menu if a user clicks on any sub-menu item. The sub menu remains open by default after you click on it, which is not very user friendly, especially if the menu is a large one. The javascript code works only on the first page load, but not after an AJAX call. Do you know where I need to put the code for it to work after an AJAX call in the theme, or how I need to make that call?

    Here’s the javascript, which works on the latest template version (http://www.aivahthemes.com/musicplay/) to hide the second sub-menu after you click on any one of the items in it. If you put this code towards the end in footer.php (just for testing purposes), it will work. But it won’t work after navigating to a different page after an AJAX callback.

    <script type=”text/javascript>

    (function($){

    var mql=window.matchMedia(“screen and (min-width: 777px)”);

    if(mql.matches){

    var mymenu=$(‘#atp_menu’).superfish({});

    $(‘.sub-menu’).on(‘click’,function(){
    $(‘#atp_menu’).children(‘li:nth-child(2)’).superfish(‘hide’);
    });

    }

    })(jQuery);

    </script>

    Your help would be appreciated.

    Thanks.

    2014-12-03 at 11:46 pm
    #6089
    Wajid Khan
    Keymaster
    • Topics: 5
    • Replies: 1543
    • Total posts: 1548
    • Post count: 1876

    Its there in ajaxify.js file located in js folder where you can add the call back. Please try contacting me via Skype if you have further issues.

    Regards,
    Mawk

You must be logged in to reply to this topic.