Manually setting submenu left/right direction

Home Forums Older releases 0.9.x Manually setting submenu left/right direction

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1321
    CCharabaruk
    Participant

    Due to client wants for a project, I need to be able to have the first half of the top-level submenus (and their lower-level subs) open to the right, but the other half of them opening to the left, except where the edge of the browser would force them to open on the other side of their parent. I’ve tried manually resetting rightToLeftSubMenus and firing a fresh itemActivate in the beforeshow event, but this just causes second-level submenus from appearing for the latter submenus.

    
        $('#main-menu').bind('beforeshow.smapi', function (e, menu) {
            console.log('beforeshow.smapi ', e, menu);
            var sm = $('#main-menu').data('smartmenus');
    
            if (sm.opts.rightToLeftSubMenus != ($(menu).parent().index() >= 3)) {
                sm.opts.rightToLeftSubMenus = ($(menu).parent().index() >= 3);
                console.log(sm.opts.rightToLeftSubMenus, sm.opts);
    
                $('#main-menu').data('smartmenus', sm).smartmenus('refresh');
                $('#main-menu').smartmenus('itemActivate', $(menu).dataSM('parentA'));
            }
        });
    

    Is there a better (i.e. actually working) method for doing this?

    #1597
    CCharabaruk
    Participant

    I figured out what I needed to do; without a guard to skip the whole operation on lower-level submenus I’d end up in a deadly cycle. The solution was to add this as the first line of the event handler:

    if ($(menu).parentsUntil('#main-menu').length != 1) return;

    Now it works just fine.

    #3548
    lgmtl
    Participant

    Hi CCharabaruk,

    I too want to just swap the submenu pop up direction from left to right, could you please tell me where exactly you added this line?

    if ($(menu).parentsUntil(‘#main-menu’).length != 1) return;

    Thanks so much!

    Brandon

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Register

You will be emailed a link to set your password.

Login

Lost password?