Saving jQuery UI Sortable's order to Backbone.js Collection

Posted by VirtuosiMedia on Stack Overflow See other posts from Stack Overflow or by VirtuosiMedia
Published on 2012-04-13T20:36:48Z Indexed on 2012/04/13 23:29 UTC
Read the original article Hit count: 321

I have a Backbone.js collection that I would like to be able to sort using jQuery UI's Sortable. Nothing fancy, I just have a list that I would like to be able to sort.

The problem is that I'm not sure how to get the current order of items after being sorted and communicate that to the collection. Sortable can serialize itself, but that won't give me the model data I need to give to the collection.

Ideally, I'd like to be able to just get an array of the current order of the models in the collection and use the reset method for the collection, but I'm not sure how to get the current order. Please share any ideas or examples for getting an array with the current model order.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jquery-ui