Last Selected Menu Item

1

Personal I have a tree structure, and I'm making a menu with the elements of it, but I need the last element to be selected. Can someone 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>
    
asked by anonymous 24.10.2016 / 20:37

0 answers