Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. [{
  2. "list_name":"list1",
  3. "list_id":"4",
  4. "created":"2011-07-07 21:21:16",
  5. "user_id":"123456"
  6. },
  7. {
  8. "list_name":"list2",
  9. "list_id":"3",
  10. "created":"2011-07-07 21:19:51",
  11. "user_key":"678901"
  12. }]
  13.  
  14. // Router
  15. App.Routers.AppRouter = Backbone.Router.extend({
  16. routes: {
  17. '': 'index'
  18. },
  19. initialize: function() {
  20. },
  21. index: function() {
  22. var listCollection = new App.Collections.ListCollection();
  23. listCollection.fetch({
  24. success: function() {
  25. new App.Views.ListItemView({collection: listCollection});
  26. },
  27. error: function() {
  28. alert("controller: error loading lists");
  29. }
  30. });
  31. }
  32. });
  33.  
  34. // Models
  35. var List = Backbone.Model.extend({
  36. defaults: {
  37. name: '',
  38. id: ''
  39. }
  40. });
  41.  
  42. App.Collections.ListStore = Backbone.Collection.extend({
  43. model: List,
  44. url: '/lists'
  45. });
  46.  
  47. // Initiate Application
  48. var App = {
  49. Collections: {},
  50. Routers: {},
  51. Views: {},
  52. init: function() {
  53. var objAppRouter = new App.Routers.AppRouter();
  54. Backbone.history.start();
  55. }
  56. };
  57.  
  58. if (already) throw new Error(["Can't add the same model to a set twice", already.id]);
Add Comment
Please, Sign In to add comment