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: Dynamic Menu Population Not Supported

Home Forums Older releases 1.0.x + Bootstrap addon Dynamic Menu Population Not Supported Reply To: Dynamic Menu Population Not Supported

#2898
schellem
Participant

The auto attach to bootstrap feature caused me a few hours of pain again today. I was converting my JSRender templated Bootstrap menu over to use Knockout so that I could include 1 less library.

I finally discovered that SmartMenu was auto attaching to this fragment prior to the KO binding

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
	      
      <ul id="navBarMenu" class="nav navbar-nav" data-bind="template: { name: 'menuSection-template', foreach: menu}">
        
      </ul>
</div>

After KO binding\templating is completed, calling

$.SmartMenus.Bootstrap.init()

does nothing. I guess it figures it has already attached to the menu fragment.

Marking the #navBarMenu with

data-sm-skip=true

and then removing it after KO binding resolved the problem.

Again, I would suggest the library not auto attach to Bootstrap menus or at least throw an error when initing a BS menu a second time.