I'm getting a bit stuck implemented a backbone comparator, I basically want to select different sorting methods based on the route and use the comparator to sort the collection. Ideally I want to keep the sorting logic encapsulated within the collection but seem to be getting stuck. For example
Requests = Backbone.Collection.extend({
model : Request,
comparator : function(ab) {
return -ab.id;
},
nooffers : function() {
return this.sortBy(function(ab) {
return ab.get('offers');
});
}
});
So by default it sorts based on the default comparator - but in my routing I wish to be able to resort e.g. do something like
routes : {
: index,
'/ordering/:order' : 'ordering'
},
ordering : function(theorder) {
ordering = theorder;
if(theorder == 'nooffers') {
Request.comparator = Request.nooffers();
}
Request.sort();
listView.render();
howitworksView.render();
}
However in that case I get an error ('c.call is not a function') any ideas?