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.

Reply To: collapsibleBehavior: accordion BUT if link is only # (hash) open the child

Home Forums Latest release 1.1.x collapsibleBehavior: accordion BUT if link is only # (hash) open the child Reply To: collapsibleBehavior: accordion BUT if link is only # (hash) open the child

#3722
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 ) );