Search code examples
jquerydrop-down-menusubmenu

Destroy / Reset jquery-menu-aim


Working in a responsive layout, so I have two versions of a menu. I want to use menu-aim on the desktop version, but remove it on smaller screens.

Looking here, there appears to be a way to kill the function, so the hover states deactivate under a specified width, but I cannot get it to work. I have commented there as well for instruction.

This is what I am trying:

function menuDelay() {
    // Super cool delay menu
    if(isDesktop()) {
        $('.mainnav > li').each(function() {
        $menu = $(this).find('.menu-header ul');
        $menu.menuAim({
            activate: activateSubmenu,
            deactivate: deactivateSubmenu,

        }); 
    });
    }
}

function menuKill() {
    $('.mainnav > li').each(function() {
        $menu = $(this).find('.menu-header ul');
        $menu.menuAim.destroy;
    });
}

Where I am using .resize() to listen for screenWidth. If it's below a threshold, run menuKill().

Mainly I am unclear how to kill all functionality of menu-aim, but if possible this is not the proper way to structure this logic, I am open to any criticism there as well.


Solution

  • Thanks to @bobbyrenwick, the call to destroy MenuAim is:

    $menu.menuAim("destroy");

    It's in the comments here.