I am dynamically generating a menu from a database table. I’m trying to set an ‘active’ class based on if the route is found in the current location.href but the dmx data binding doesn’t appear to have a handle to the window.
Any ideas?
Here’s my client-side code:
<ul class="list-unstyled components">
<div dmx-repeat:repeat1="sc_menu_list.data.menu">
<li dmx-class:active="window.location.href.indexOf(route)>0">
<a dmx-bind:href="route.length>0 ? route : '#' + name + '_submenu'" dmx-class:dropdown-toggle="(sc_menu_list.data.repeat_submenu[$index].submenu.count() > 0)"
dmx-bind:data-toggle="(sc_menu_list.data.repeat_submenu[$index].submenu.count() > 0)?'collapse':null" aria-expanded="false">
<i dmx-bind:class="icon"></i> <span dmx-text="name"></span>
</a>
</li>
<ul class="collapse list-unstyled" dmx-bind:id="name + '_submenu'" dmx-bind:repeat="sc_menu_list.data.repeat_submenu[$index].submenu" is="dmx-repeat">
<li>
<a dmx-bind:href="route">
<i dmx-bind:class="icon"></i> <span dmx-text="name"></span>
</a>
</li>
</ul>
</div>
</ul>
Community Page
Last updated:
Last updated: