Skip to content

Conversation

@dwickern
Copy link

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 !!

@dwickern
Copy link
Author

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')

@ebryn
Copy link
Owner

ebryn commented Apr 24, 2014

@jnovatnack can you take a stab at this? @dwickern has provided failing tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants