Refresh observableArray when items are not observables

前端 未结 5 1212
孤街浪徒
孤街浪徒 2020-12-01 15:58

Basically I have an observableArray and the values for each item are not an observable. This means when I change an item value the UI within a foreach loop of the observable

5条回答
  •  离开以前
    2020-12-01 16:33

    Yes, you can call valueHasMutated function for your array:

    yourArray.valueHasMutated();
    

    EDIT: If first didn't help you can do 'dirty' refresh:

    self.refresh = function(){
        var data = self.array().slice(0);
        self.array([]);
        self.array(data);
    };
    

    Here is working fiddle: http://jsfiddle.net/vyshniakov/FuEy6/2/

提交回复
热议问题