Created
December 4, 2013 19:40
-
-
Save meandavejustice/7794166 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// currently sorting my collection with this comparator. | |
// It sets up a relationship so that a Parent Item should be before its sub-items(you can think of these as sub tasks) | |
// 'parent' attribute is just the 'pk' of the parent item. | |
// This is working fantastically but I need to sort at a higher level above this descending from an attribute called | |
// 'created_at'. | |
// the `else` refers to items that are either parents, or items that have no relationship to any others. | |
comparator: function(item) { | |
if (item.isSubItem()) { | |
return [item.get('parent'), item.get('pk')]; | |
} else { | |
return [item.get('pk'), 0]; | |
} | |
}, | |
// so it really should look something like this when complete. | |
// [itemCreatedTodayWithNoParents, parentItemCreatedYesterday, subItemOfpreviousParentCreatedWhenever, itemCreatedLastWeek] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment