1
Guys, I have a tree structure, and I’m making a menu of her elements, but I need the last element selected. Someone can help me?
viewModel = kendo.observable({
currentItems: [],
navigation: [],
initialize: function () {
this.set('currentItems', plantModel.children);
this.navigation.push(plantModel);
},
selectItem: function (e) {
var item = e.data;
this.navigation.push(item);
this.set('currentItems', item.children);
//debugger;
},
selectNavigationItem: function (e) {
var item = e.data;
var select = null;
while (this.navigation.length > 0 && this.navigation[this.navigation.length - 1] != item) {
this.navigation.pop();
}
this.set('currentItems', item.children);
}
});
<fieldset class="breadcrumb" style="">
<span class="crumbs">
<ul data-role="repeater" data-bind="source: navigation" data-template="navigation-template" style="margin-left: -40px;margin-top: -10px;"></ul>
<script id="navigation-template" type="text/x-kendo-template">
<div><span class="crust homeCrumb" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="javascript:" id="tst" data-bind="click: selectNavigationItem" class="crumb" itemprop="url"><span itemprop="title" >#=name#</span></a>
<span class="arrow"><span></span></span></div>
</span>
</script>
</span>
</fieldset>
I’ve done something similar where I generated the elements by jquery and set the level and id of each item and at the end it was easy to select the last one I wanted
– Almeida