سؤال

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)

هل كانت مفيدة؟

المحلول

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)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top