带有显示值的Ember链接属性

时间:2016-01-13 10:03:24

标签: javascript jquery ember.js

我的Ember Route课程如下所示

export default Ember.Route.extend({
    selectedRowCount: 10,

    actions: {
        dataLoaded: function(resp) {
            this.set('gridPrms.summaryObj.total.value', resp.numRows) ;
            var additional = this.get('gridPrms.summaryObj.additional');
            additional.push({label: 'Selected', value: this.get('selectedRowCount')});
            this.set('gridPrms.summaryObj.additional', additional);
        },
        rowSelected: function(data){
            // This gets called and updates selectedRowCount, but the same is not reflected on UI
            this.set('selectedRowCount',this.get('selectedRowCount') + 1);
        },
        rowDeselected: function(data){
            // This gets called and updates selectedRowCount, but the same is not reflected on UI
            this.set('selectedRowCount',this.get('selectedRowCount') - 1);
        }
    }
}); 

我的模板也是

{{my-grid params=this.gridPrms dataLoaded="dataLoaded" rowSelected="rowSelected" rowDeselected="rowDeselected"}}

我的摘要对象如下

var summaryObj = {
    total: {
        label: "Items",
        value: "15"
    },
    additional: []
};

我的问题是,当我渲染页面时,我的网格加载并设置"额外的"来自路线属性的属性(选定标签)" selectedRowCount"正确地

但是同样没有得到更新"在UI"当用户进行行选择/取消选择时

如何链接这两件事?

1 个答案:

答案 0 :(得分:0)

你需要改变这个:

{{my-grid params=this.gridPrms dataLoaded="dataLoaded" rowSelected="rowSelected" rowDeselected="rowDeselected"}}

到此:

{{my-grid params=this.gridPrms dataLoaded="dataLoaded" rowSelected=rowSelectedCount rowDeselected=rowDeselectedCount}}

我认为,在你的my-grid组件中,你有类似的东西:

{{rowSelected}}