Last active
August 29, 2015 14:10
-
-
Save filipmares/ee084202f7a131929801 to your computer and use it in GitHub Desktop.
Talko Web Libraries That Enable Our Modular Design
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Task ItemView | |
var TaskView = Backbone.Marionette.ItemView.extend({ | |
template: "#task-template" | |
}); | |
// CollectionView of Task ItemViews | |
var TasksCollectionView = Backbone.Marionette.CollectionView.extend({ | |
childView: TaskView | |
}); | |
// Collection of Tasks | |
var TasksCollection = Backbone.Collection.extend({ | |
comparator: "name" | |
}); | |
// Create Tasks Collection | |
var tasksCollection = new TasksCollection(); | |
// Create Tasks CollectionView and bind it to collection | |
var tasksCollectionView = new TasksCollectionView({ | |
collection: tasksCollection | |
}); | |
// Add a new Task to collection. CollectionView creates and adds the TaskView automagically | |
tasksCollection.add({ | |
name: "My Test Task" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment