Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

carasmo

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • carasmo
    Participant

    This is resolved. I can’t find a way to mark it though.

    carasmo
    Participant

    Okay that code above is wrong for the current open. Needs to come after.

    //__ SmartMenus.org args
    var $primary_menu = $('.menu-secondary');
    
    /* 
     * if parent is a #, toggle children
     * if parent is a #, toggling the title closes children
     * if parent is a link, go to url on first click
    */
    $primary_menu.smartmenus( {
        subMenusMinWidth:    '250px',
        showTimeout:         '300',
        markCurrentItem:     true,
        collapsibleBehavior: 'accordion-link',
        hideOnClick:         false
        
    } ).on( 'select.smapi', function( e, item ) {
        
        var obj   = $(this).data( 'smartmenus' ),
            $item = $(item);
            
        if ( obj.isCollapsible() && $item.is('[href="#"]') ) {
            var $sub = $item.dataSM( 'sub' );
            if ( $sub && !$sub.is( ':visible') ) {
                obj.itemActivate( $item, true );
            }
            return false;
        }
    } ).bind('click.smapi', function( e, item ) {
    
        var obj = $( this ).data( 'smartmenus' );
        
        if ( obj.isCollapsible() ) {
            var $sub = $( item ).dataSM( 'sub' );
            if ( $sub && $sub.is( ':visible' ) ) {
                obj.menuHide( $sub );
                return false;
            }
        }
    } );
    		
    //__ keep open on current
    $primary_menu.smartmenus( 'itemActivate', $primary_menu.find( 'a.current' ).eq( -1 ) );	
    
    carasmo
    Participant

    That works great!

    Here’s the final js to do the following:

    -Keep open on current url
    -If parent only an # toggle the children and close on click
    -If link is a link go to the url

    Also checked that the aria labels worked and they do!

    You are amazing — thank you so much.

    
    
    
    //__ SmartMenus.org args
    var $primary_menu = $('.menu-secondary');
    
    //__ keep open on current
    $primary_menu.smartmenus( 'itemActivate', $primary_menu.find( 'a.current' ).eq( -1 ) );
    
    /* 
     * if parent is a #, toggle children
     * if parent is a #, toggling the title closes children
     * if parent is a link, go to url on first click
    */
    $primary_menu.smartmenus( {
        subMenusMinWidth:    '250px',
        showTimeout:         '300',
        markCurrentItem:     true,
        collapsibleBehavior: 'accordion-link',
        hideOnClick:         false
        
    } ).on( 'select.smapi', function( e, item ) {
        
        var obj   = $(this).data( 'smartmenus' ),
            $item = $(item);
            
        if ( obj.isCollapsible() && $item.is('[href="#"]') ) {
            var $sub = $item.dataSM( 'sub' );
            if ( $sub && !$sub.is( ':visible') ) {
                obj.itemActivate( $item, true );
            }
            return false;
        }
    } ).bind('click.smapi', function( e, item ) {
    
        var obj = $( this ).data( 'smartmenus' );
        
        if ( obj.isCollapsible() ) {
            var $sub = $( item ).dataSM( 'sub' );
            if ( $sub && $sub.is( ':visible' ) ) {
                obj.menuHide( $sub );
                return false;
            }
        }
    } );
    
Viewing 3 posts - 1 through 3 (of 3 total)