Skip to content

Wrap around <ul> only #48

@bbashy

Description

@bbashy

Got pretty much everything working. Thanks for the package!

One small issue with dropdown using UIKit. When I use ->submenuIf() and have ->wrap('div', ['class' => 'uk-navbar-dropdown']), it adds it around the <a> as well which I don't want. Any way to do that? Tried quite a few different ideas but none worked.

Menu::macro('main', function() {
    $menu = Menu::new()
        ->addClass('uk-navbar-nav')
        ->setActiveClass('uk-active')
        ->route('home', 'Home')
        ->submenuIf($isAdmin, '<a href="#">Admin</a>', function (Spatie\Menu\Laravel\Menu $menu) {
            $menu
                //->wrap('div', ['class' => 'uk-navbar-dropdown'])
                ->addClass('uk-nav uk-navbar-dropdown-nav')
                ->route('admin.item', 'Item')
                ->route('admin.item2', 'Item 2')
            ;
        })
        ->setActiveFromRequest()
    ;

    return $menu;
});

Need this format;

<li>
    <a href="#">Parent</a>
    <div class="uk-navbar-dropdown">
        <ul class="uk-nav uk-navbar-dropdown-nav">
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
        </ul>
    </div>
</li>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions