Created
August 1, 2014 21:43
-
-
Save taylor-smith/67e071cbeabff64d0675 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
var TodoItem = Backbone.Model.extend({}); | |
var TodoView = Backbone.View.extend({ | |
render: function(){ | |
var html = '<h3>' + this.model.get('description') + '</h3>' | |
this.$el.html(html); | |
return this; | |
} | |
}); | |
var todoItem = new TodoItem( | |
{ description: "Pick up milk", | |
status: "incomplete", | |
id: 1 } | |
); | |
var todoView = new TodoView({ model: todoItem }) | |
console.log(todoView.el); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check out this file - https://github.com/clamstew/backbone-todo-app/blob/master/app/assets/javascripts/app/views/todo-list-view.js
Basically, when you created a new instance of the View object, you need to pass it an "
el
" or it won't know where to put things on the DOM.So something like: