GeForce RTX 4090
GeForce RTX 4090

Reputation: 3498

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"};
}

Upvotes: 0

Views: 36

Answers (1)

Jose Luis
Jose Luis

Reputation: 994

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

Upvotes: 1

Related Questions