バックボーンコンパレータが実装されていますが、基本的にルートに基づいて異なるソート方法を選択し、コンパレータを使用してコレクションをソートする必要があります。理想的には、コレクション内にカプセル化されたソートロジックを保持したいが、固まっているようだ。たとえば、が正しくバックボーンコンパレータを実装しています
Requests = Backbone.Collection.extend({
model : Request,
comparator : function(ab) {
return -ab.id;
},
nooffers : function() {
return this.sortBy(function(ab) {
return ab.get('offers');
});
}
});
デフォルトでは、デフォルトのコンパレータに基づいてソートされますが、私のルーティングでは、
routes : {
"" : "index",
'/ordering/:order' : 'ordering'
},
ordering : function(theorder) {
ordering = theorder;
if(theorder == 'nooffers') {
Request.comparator = Request.nooffers();
}
Request.sort();
listView.render();
howitworksView.render();
}
この場合、エラー(「c.callは機能ではありません」)が表示されます。
回答は良かったですが、質問にも答えが出てきました。:-) – jmk2142