Advertisement
rburgosnavas

bb collection

Dec 17th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // The collection....
  2. var Stopcodes = Backbone.Collection.extend({
  3.  
  4.   model: Stopcode,
  5.  
  6.   url: function() {
  7.     var api = stopselector.API_ROOT;
  8.     var agency_id = Agency.get('id');
  9.     return api + '/agencies/' + agency_id + '/stopcodes/9269';
  10.   },
  11.  
  12.   parse: function(response) {
  13.     return response;
  14.   }
  15.  
  16. });
  17.  
  18. // The model...
  19. var Stopcode = Backbone.Model.extend({
  20.  
  21.   defaults: function() {
  22.     return {
  23.       id: '5650',
  24.       lat: null,
  25.       lon: null,
  26.       name: null,
  27.       code: null,
  28.       hidden: false,
  29.       showDestinationSelector: true,
  30.       route: null,
  31.       directions: []
  32.     };
  33.   }
  34. });
  35.  
  36. // The fetch call to the collection (this is done in another file)...
  37. Stopcodes.fetch({
  38.   reset: true,
  39.   error: this.errorHandler,
  40.   success: function(collection, response, options) {
  41.     console.log("@Stopcodes.fetch()");
  42.     console.log("collection = ");
  43.     console.log(collection);
  44.     console.log("response = ");
  45.     console.log(response);
  46.     console.log("options = ");
  47.     console.log(options);
  48.     console.log("\n");
  49.     _.each(response, function(r) {
  50.       console.log(r);
  51.           stopcodes.push(r);
  52.         });
  53.     console.log(stopcodes);
  54.   }
  55. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement