Skip to content

Commit

Permalink
Add 'value' alias for data and fire changed event when model is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuwen Qian authored and anthonykoerber committed Mar 2, 2016
1 parent 176e9b4 commit 4979338
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/mm-repeater/mm-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
}
},

get value() { return this.data; },
set value(newVal) { if (newVal instanceof Array) this.data = newVal; },

ready: function() {
var templateTag = this.queryEffectiveChildren('template');
this.set('template', templateTag.innerHTML);
Expand Down Expand Up @@ -55,6 +58,7 @@
if(name && value) {
var index = this.$.repeater.indexForElement(target);
this.set('data.'+(index)+'.'+name, value);
this.debounce('changed', this._changed);
}
},

Expand All @@ -65,6 +69,11 @@
_removeRow: function(e) {
var index = this.$.repeater.indexForElement(e.target);
this.splice('data', index, 1);
this.debounce('changed', this._changed);
},

_changed: function() {
this.fire('changed', { value: this.data });
}
});

Expand Down

0 comments on commit 4979338

Please sign in to comment.