PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/cdnsrc/js/collection/DocumentCollection.js

https://github.com/tauren/Learning-backbone.js
JavaScript | 30 lines | 27 code | 1 blank | 2 comment | 0 complexity | 08a6c6455a63ea5a3cd118d9989975ea MD5 | raw file
Possible License(s): Apache-2.0
  1. var DocumentCollection = Backbone.Collection.extend({
  2. initialize : function (args) {
  3. return this;
  4. }
  5. // A helper method to allow a collection to insert new models without
  6. // requiring user input.
  7. ,addRandomDocument : function (i)
  8. {
  9. var d = new Date();
  10. var instance =
  11. {
  12. id:
  13. i
  14. ,summary:
  15. 'Random: ' + randomWords(Math.floor(Math.random()*8)+2)
  16. ,created:
  17. d.getMonth() + '/' + d.getDate() + '/' + d.getFullYear()
  18. ,modified:
  19. d.getMonth() + '/' + d.getDate() + '/' + d.getFullYear()
  20. ,description:
  21. 'This content was randomly generated. ' +
  22. randomWords(Math.floor(Math.random()*106)+2)
  23. ,author:
  24. 'Aaron Greenlee'
  25. };
  26. var doc = new DocumentModel(instance);
  27. this.add( doc );
  28. }
  29. });