/public/js/Collection.js

https://bitbucket.org/P0PE/backbone-training-part2 · JavaScript · 17 lines · 17 code · 0 blank · 0 comment · 0 complexity · c22df0c1537dccda4859bc35caaaed8b MD5 · raw file

  1. define(['backbone','Model', 'jquery', 'underscore', 'dustjs-linkedin'], function(Backbone, Model, $, _, dust) {
  2. var Collection = Backbone.Collection.extend({
  3. initialize: function () {
  4. console.log("collection initialized");
  5. },
  6. model: Model,
  7. url: 'http://tiy-fee-rest.herokuapp.com/collections/pope5',
  8. toJSON: function(){
  9. var arr = [];
  10. _.each(this.models, function() {
  11. arr.push(model.toJSON());
  12. });
  13. return arr;
  14. }
  15. });
  16. return Collection;
  17. });