mardi 19 décembre 2017

knockout checkbinding get last (de)selected element

I have show or hide div's that are selected in my settings box. For this i have to use a knockout checked binding but this only returns me an array of selected elements but i need the last changed element an then need to know if it's selected or not. This to prevent unnecessary looping.

the index.cshtml:

<input type="checkbox" class="checkbox checkbox-category" name="checkbox" data-bind="attr: {id: 'checkbox' + category.id }, checked: $root.enabledCategories, checkedValue: category" checked />

the typescript classe:

 enabledCategories: KnockoutObservableArray<Category>;

        this.enabledCategories = ko.observableArray([]);

        this.enabledCategories(this.categories());
this.enabledCategories.subscribe(function (val) {

            console.log(val);              

        });




Aucun commentaire:

Enregistrer un commentaire