Is it possible to give the output of serialize or toArray back to the ui-sortable component and have it reorder at runtime?
digitalpowers opened this issue · 5 comments
I saved my sorted list of objects (to a database but probably not important) by using toArray but now I want to restore the order when I come back to the page later. However while I can get the array out of the database when the controller starts I cant figure out how to reorder the list.
Note: the list provided by the controller is made of complex objects not just a list of id's. They load from a rest interface. What I would love is to be able to provide the preferred order back to the ui-sortable but if any objects don't exist or new objects do exist it would handle it gracefully.
I feel like i might just be barking up the waaay wrong tree but to be fair I am not really a UI guy so it might not be surprising.
Can't you just assign your restored array to your ngModel scope variable?
I am hoping I just dont understand but the serialized list is just the id's of the actual model that is being serialzied. So I cant just assign that list of id's to the model right?
Can you share a sample object for your ngModel and the serialized array?
I guess that this is not so much related to ui-sortable and more of a "how to program this" question.
Forking one of the codepen examples found in README would be ideal.
Perhaps you were right, I ended up using the ordered array to sort the backing object after it was loaded, originally I didnt think that worked because the sort order didnt visibly change, i had to trigger a digest or whatever. I am definately a noob in this area sorry :)
I'm glad you found your way around 👍