Ember.js 余烬中数值模型属性的排序

Ember.js 余烬中数值模型属性的排序,ember.js,Ember.js,我有一个非常基本的价格模型,看起来像这样: App.Price = DS.Model.extend({ value: DS.attr() }); App.Price.reopenClass({ FIXTURES: [ { id: 1, value: 29.99 }, { id: 2, value: 39.99 }, { id: 3, value: 49.99 }, { id: 4, value: 55.99 }

我有一个非常基本的
价格
模型,看起来像这样:

App.Price = DS.Model.extend({
    value: DS.attr()
});

App.Price.reopenClass({
    FIXTURES: [
        { id: 1, value: 29.99 },
        { id: 2, value: 39.99 },
        { id: 3, value: 49.99 },
        { id: 4, value: 55.99 }
    ]
});
以下是使用此模型的路线:

App.PricingRoute = Ember.Route.extend({
    model: function(){
        return this.store.find('price');
    }
});
在控制器中,我将排序设置为基于
属性:

App.PricingController = Ember.ArrayController.extend({
    sortProperties: ['value'],
    sortAscending: true
});
然后,我希望按排序顺序显示我的模板(在Jade中):

{{#each price in this}}
    li.price-levels__value {{price.value}}
        .price-levels__remove("{{action 'delete' price.id}}")
{{/each}}
问题是它们没有分类。有趣的事实是,如果我将
value
属性的类型更改为strings,排序确实有效

例如


那么,如何对数值模型属性进行排序呢?

您使用的是哪个版本的Ember?在这个例子中,你能让它失败吗?我使用的是Ember 1.9.1,与您的示例中相同。您的示例帮助我认识到,在初始输出时,它对它们进行了正确排序,但当我创建新记录时,它显示在列表的底部,而不是插入到正确的位置。当值为字符串时,会发生上述行为,但当值为整数时,则不会发生上述行为。有什么想法吗?你能在我上面的jsbin示例中复制它并发布一个链接吗?然后我可以看一下好吧,我已经把它添加到你的jsbin了!现在有一个表单可以在提交时创建新记录。新记录会自动添加到列表中,但只是附加到末尾,而不是排序。让我知道你认为我错过了什么。非常感谢!我想我已经明白了。或者至少是一个解决办法。。。我必须从表单中获取值,并在将其分配给模型时通过parseFloat运行它。这似乎奏效了。我怎样才能相信你帮助解决了这个问题?
{ id: 1, value: '29.99' }
{ id: 2, value: '39.99' }
etc.