Skip to content

Instantly share code, notes, and snippets.

Created May 8, 2014 10:31
Show Gist options
  • Save anonymous/0fa453663e5f5d312d24 to your computer and use it in GitHub Desktop.
Save anonymous/0fa453663e5f5d312d24 to your computer and use it in GitHub Desktop.
"use strict";
$(function() {
var Todo = Backbone.Model.extend({
defaults: function(){
title: "Something to remember",
done: false
},
toggle: function(){
this.save({done: !this.get("done")});
}
});
var TodoModel = new Todo;
//Collections
/* var Todos = Backbone.Collection.extend({
model: Todo
});
*/
//Collection filled
/* var todos = new Todos({
new Todo({title: "one",}),
new Todo({title: "two"})
})*/
var TodosView = Backbone.View.extend({
tagName: 'li',
//template: _.template($('#paragraph').html()),
events: {
"click ": "something"
},
initialize: function(){
this.listenTo(this.model, 'change', this.render);
},
render: function(){
this.$el.html(this.model.get('title'));
},
something: function() {
console.log("Hoi");
//this.$el.text(this.model.get("title"));
}
})
var App = Backbone.View.extend({
el: 'body',
initialize: function(){
this.listenTo(services, 'change', this.render);
}
})
var View = new TodosView;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment