javascript - Alphabetically sorting a backbone collection using a key -
i have collection needs sorted on particular key ('display'), know backbone has default comparator not defined default, @ loss of how implement it
var listcollection = new backbone.collection(rebuiltarray.map(function(text){ return { attribute: text, displaynames: displaynames[text] }; }));
thanks in advance help
try following
var listcollection = backbone.collection.extend({ comparator: 'displaynames' }); var listcollection = new listcollection(rebuiltarray.map(function(text){ return { attribute: text, displaynames: displaynames[text] }; }));
Comments
Post a Comment