Skip to content

Instantly share code, notes, and snippets.

@filipmares
Last active August 29, 2015 14:10
Show Gist options
  • Save filipmares/ee084202f7a131929801 to your computer and use it in GitHub Desktop.
Save filipmares/ee084202f7a131929801 to your computer and use it in GitHub Desktop.
Talko Web Libraries That Enable Our Modular Design
// 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