ember-model
ember-model copied to clipboard
Fix dirty tracking for Number attr
Dirty tracking is broken when setting a number attr with a numeric string.
var Model = Ember.Model.extend({ num: attr(Number) });
var obj = Model.create({ num: 1 });
obj.set('num', '2'); // dirty
obj.save(); // clean
obj.set('num', '2'); // dirty !!
This problem happens when I bind an input to a Number attribute. My workaround is to use a computed property in the controller which converts string to number in the setter:
myNum: function(key, value) {
if (arguments.length > 1) {
this.set('model.myNum', parseInt(value));
}
return this.get('model.myNum');
}.property('model.myNum')
@jnovatnack can you take a stab at this? @dwickern has provided failing tests