简体   繁体   中英

Editing one item in a list in Knockout JS

I have a demo application where I've managed to implement changing all items and sorting all items. Now I would like to update only one item at position [1] in the array of the list so that the list updates. How can I do it?

this.changeOne=function(){
this.allItems[1]={name:"jjjjjjjjjjjjjjjjjjjjjj"};
}

The first element is this.allItems()[0] .

Then, you only need to change the name property.

Like this:

    this.changeOne=function(){
        this.allItems()[0].name("jjjjjjjjjjjjjjjjjjjjjj");
    }

In this function you need to check if there is elements (I not checked it!!).

More information at this link observable arrays

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM