Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dirty tracking for Number attr #347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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