Commit 57c83b0d authored by Aaron Boushley's avatar Aaron Boushley

Remove tight coupling of the model to the view.

parent 0774dd53
......@@ -19,10 +19,9 @@ define(['underscore', 'backbone'], function(_, Backbone) {
this.save({done: !this.get("done")});
},
// Remove this Todo from *localStorage* and delete its view.
// Remove this Todo from *localStorage*.
clear: function() {
this.destroy();
this.view.remove();
}
});
......
......@@ -24,9 +24,9 @@ define([
// a one-to-one correspondence between a **Todo** and a **TodoView** in this
// app, we set a direct reference on the model for convenience.
initialize: function() {
_.bindAll(this, 'render', 'close');
_.bindAll(this, 'render', 'close', 'remove');
this.model.bind('change', this.render);
this.model.view = this;
this.model.bind('destroy', this.remove);
},
// Re-render the contents of the todo item.
......@@ -68,11 +68,6 @@ define([
if (e.keyCode == 13) this.close();
},
// Remove this view from the DOM.
remove: function() {
$(this.el).remove();
},
// Remove the item, destroy the model.
clear: function() {
this.model.clear();
......
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