I am inserting a list like using knockout (observableArray):
1.apple delete
2.banana delete
3.mango delete
4.pineapple delete
When I delete “2.banana delete“, the list appears like:
1.apple delete
3.mango delete
4.pineapple delete
But I want it to appear like:
1.apple delete
2.mango delete
3.pineapple delete
The array is like: this.list=ko.observableArray({num:1,name:apple});
I am using “foreach” and “push” function to add more elements and “remove” function to delete.
Plz help me to make the list “num” update as I delete any element.
You could use $index inside of your foreach template to display the number. This is a feature new to Knockout 2.1, as shown here: http://www.knockmeout.net/2012/05/knockout-2-dot-1-is-out.html