Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [{
- "list_name":"list1",
- "list_id":"4",
- "created":"2011-07-07 21:21:16",
- "user_id":"123456"
- },
- {
- "list_name":"list2",
- "list_id":"3",
- "created":"2011-07-07 21:19:51",
- "user_key":"678901"
- }]
- // Router
- App.Routers.AppRouter = Backbone.Router.extend({
- routes: {
- '': 'index'
- },
- initialize: function() {
- },
- index: function() {
- var listCollection = new App.Collections.ListCollection();
- listCollection.fetch({
- success: function() {
- new App.Views.ListItemView({collection: listCollection});
- },
- error: function() {
- alert("controller: error loading lists");
- }
- });
- }
- });
- // Models
- var List = Backbone.Model.extend({
- defaults: {
- name: '',
- id: ''
- }
- });
- App.Collections.ListStore = Backbone.Collection.extend({
- model: List,
- url: '/lists'
- });
- // Initiate Application
- var App = {
- Collections: {},
- Routers: {},
- Views: {},
- init: function() {
- var objAppRouter = new App.Routers.AppRouter();
- Backbone.history.start();
- }
- };
- 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