This is not an issue, but a question , sorry for posting it here and thanks in advance.
Thanks!.
Use toArray
Hi @rakeshrockb,
Here's what I've done, and it works pretty well. The second parameter of the onEnd event is the index of each item.
$scope.SortableOptions = {
onEnd: function (evt) {
angular.forEach(evt.models, function(obj,index){
//do something with the index
});
},
};
Thanks matt,
managed to do it via onUpdate. I couldnt use toArray, as i always needed first one to remain with data-id=0 in order to save his possition as first one.
So my code was:
onUpdate: function (evt) {
[].forEach.call(evt.from.getElementsByClassName('omaido__sortable_item'), function (el,index) {
el.setAttribute("data-id",index);
});
},
this way, data-id was always from 0 to how many i have, while items changed around.
Most helpful comment
Thanks matt,
managed to do it via onUpdate. I couldnt use toArray, as i always needed first one to remain with data-id=0 in order to save his possition as first one.
So my code was:
this way, data-id was always from 0 to how many i have, while items changed around.