forked from willeeklund/JavaScriptForAnalysts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.js
More file actions
28 lines (27 loc) · 639 Bytes
/
Copy pathtodo.js
File metadata and controls
28 lines (27 loc) · 639 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
define(
['jquery', 'underscore', 'backbone'],
function($, _) {
var Todo = Backbone.Model.extend({
defaults: {
title: '',
completed: false
},
initialize: function() {
this.on('change', function () {
console.info('Model changed!')
})
},
toggle: function () {
console.log("start state: ", this.get('completed'));
this.set('completed', !this.get('completed'));
console.log("state changed: ", this.get('completed'));
},
setListener: function(listeningView) {
console.log("Model", this, "setListener()")
this.on('change', function() {
listeningView.render();
});
}
});
return Todo;
});