Replace between 2 items in observableArray - knockout
- by Yojik
im tring to Replace between 2 items in observableArray with knockout but something is wrong..
after the replace of the items ,i will change and send the displayOrder property (in both itmems) to the server (or should i take other approach for this)
rankDownMessage: function () {
console.log("ranking down msg");
var currentItemindex = viewModel.messages.indexOf(this);
var nextItemIndex = currentItemindex + 1;
viewModel.messages.replace(
viewModel.messages()[nextItemIndex],
viewModel.messages()[currentItemindex]
);
}
only the first item changed to the second item but the second item doesnt become the first one