Skip to content

Instantly share code, notes, and snippets.

@meirish
Created December 6, 2011 19:46
Show Gist options
  • Save meirish/1439644 to your computer and use it in GitHub Desktop.
Save meirish/1439644 to your computer and use it in GitHub Desktop.
define([
'jquery',
'underscore',
'backbone',
'store',
'models/location'
], function($,_,Backbone, Store, Location){
var LocationList = Backbone.Collection.extend({
model: Location,
initialize: function( models, options){
// Can be 'departures', 'destinations', 'routine-stops'
this.localStorage = new Store(options.store);
},
sortBy: function( modelAttr ){
if ( _.indexOf( _.keys(this.model.prototype.defaults), modelAttr) < 0 )
return;
this.compareBy = modelAttr;
},
comparator: function( model ){
return model.get(this.compareBy);
}
});
return LocationList;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment