Commit ba3a573b authored by Aaron Boushley's avatar Aaron Boushley

Updating the template to use the content it has present.

parent 57c83b0d
<div class="todo <%= done ? 'done' : '' %>">
<div class="display">
<input class="check" type="checkbox" <%= done ? 'checked="checked"' : '' %> />
<div class="todo-content"></div>
<div class="todo-content"><%= content %></div>
<span class="todo-destroy"></span>
</div>
<div class="edit">
<input class="todo-input" type="text" value="" />
<input class="todo-input" type="text" value="<%= content %>" />
</div>
</div>
......@@ -17,7 +17,8 @@ define([
"click .check" : "toggleDone",
"dblclick div.todo-content" : "edit",
"click span.todo-destroy" : "clear",
"keypress .todo-input" : "updateOnEnter"
"keypress .todo-input" : "updateOnEnter",
"blur .todo-input" : "close"
},
// The TodoView listens for changes to its model, re-rendering. Since there's
......@@ -32,18 +33,8 @@ define([
// Re-render the contents of the todo item.
render: function() {
$(this.el).html(this.template(this.model.toJSON()));
this.setContent();
return this;
},
// To avoid XSS (not that it would be harmful in this particular app),
// we use `jQuery.text` to set the contents of the todo item.
setContent: function() {
var content = this.model.get('content');
this.$('.todo-content').text(content);
this.input = this.$('.todo-input');
this.input.bind('blur', this.close);
this.input.val(content);
return this;
},
// Toggle the `"done"` state of the model.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment