Created
May 8, 2014 10:31
-
-
Save anonymous/0fa453663e5f5d312d24 to your computer and use it in GitHub Desktop.
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
"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