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="todo <%= done ? 'done' : '' %>">
<div class="display"> <div class="display">
<input class="check" type="checkbox" <%= done ? 'checked="checked"' : '' %> /> <input class="check" type="checkbox" <%= done ? 'checked="checked"' : '' %> />
<div class="todo-content"></div> <div class="todo-content"><%= content %></div>
<span class="todo-destroy"></span> <span class="todo-destroy"></span>
</div> </div>
<div class="edit"> <div class="edit">
<input class="todo-input" type="text" value="" /> <input class="todo-input" type="text" value="<%= content %>" />
</div> </div>
</div> </div>
...@@ -17,7 +17,8 @@ define([ ...@@ -17,7 +17,8 @@ define([
"click .check" : "toggleDone", "click .check" : "toggleDone",
"dblclick div.todo-content" : "edit", "dblclick div.todo-content" : "edit",
"click span.todo-destroy" : "clear", "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 // The TodoView listens for changes to its model, re-rendering. Since there's
...@@ -32,18 +33,8 @@ define([ ...@@ -32,18 +33,8 @@ define([
// Re-render the contents of the todo item. // Re-render the contents of the todo item.
render: function() { render: function() {
$(this.el).html(this.template(this.model.toJSON())); $(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 = this.$('.todo-input');
this.input.bind('blur', this.close); return this;
this.input.val(content);
}, },
// Toggle the `"done"` state of the model. // 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