Reputation: 5668
I have an input input element like this
<input id="txtId" type="text" data-bind="value: query, valueUpdate: 'keyup'">
and also I have a collection that bind to this input
<script>
var terms = [{name: blah,...,... }];
var viewModel = { query: ko.observable('') };
viewModel.terms = ko.dependentObservable(function () {
var search = this.query().toLowerCase();
return ko.utils.arrayFilter(terms, function (term)
{
return term.name.toLowerCase().indexOf(search) >= 0;
});
}, viewModel);
ko.applyBindings(viewModel);
</script>
I want to choice available items and they should appear in my input element. But item bind with collection and collection begin to change. I need somehow to break bindings. So help please)
Upvotes: 4
Views: 571
Reputation: 5668
I have solved that question. I have created a flag (ability to modify collection) this class is not observable and with it I can manipulate my collection)
Upvotes: 4