New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection Sorting + Updating View #41
Comments
You can use http://documentcloud.github.com/backbone/#Collection-comparator If you change the Hope that helps... |
Thanks - yes that makes sense. So in my case after each refresh, add etc... I would need to clear my view correct? For example: |
Yes, in the
No, you just have to insert new views at the appropriate location in the DOM. Instead of just a simple jQuery |
To do insert before or after - What would be the most efficient way to find it's neighbours in the Collection? I was thinking if I bind to the add event and get the index of the newly inserted model I could check to see what the next index is or something like that. |
Yep, you can do:
... to get its position within the collection. From there, you can look up the adjacent elements, either by
|
Very cool - thanks for the help. |
I've just started playing with Backbone. Wondering what's the best approach for sorting and updating a view. I put together a little demo at http://backbone.line37.com/ but I'm sure there's a better way to do this:
alphaSort:function()
{
var alphabetical = Contacts.sortBy(function(contact) {
return contact.get("firstname").toLowerCase();
});
The text was updated successfully, but these errors were encountered: