I need to implement 2 buttons (next, previous) for array elements of an observable array. Is there any default function or any way to navigate between elements of the array?
Ex:
var mainArray = ko.observableArray([{id:1,name:'one'},{id:2,name:'two'}]);
When I click the next button, it should return the next object (like ko.utils.arrayFirst() returns the given object)
Any help?
Nope, there is no "default" way to do this.
RoyJ's comment is spot on about how to do it yourself. Let me turn it into a working example:
It utilizes:
prev
andnext
to change that index (for sofar valid/possible);The view (html) is just for demo purposes.