Kendo UI MVVM - 带动作的事件"添加"解雇了两次

时间:2015-03-26 19:52:24

标签: javascript jquery kendo-ui kendo-datasource kendo-mvvm

在viewmodel中,我有一个名为" curRec"的对象。其属性绑定到视图上的控件。例如,curRec.id,curRec.targetScore等

此外,curRec有一个类型为array的属性,名为" actions"。我正在使用Kendo UI中的数据模板渲染动作。

当我将新记录推入curRec.actions时,内部剑道会通过动作触发事件"添加"两次,因此一次添加两行。在一段时间内,数组只包含一个记录,因为我只按了一行。

这里有一些代码:

addMore: function(e) {
    e.preventDefault();
    this.get("curRec.actions").push( new ActionModel({}) );
},
removeMore: function (e) {
    e.preventDefault();
    var action = e.data;
    var index_item_to_remove = this.get("curRec.actions").indexOf(action);
    this.get("curRec.actions").splice(index_item_to_remove, 1);
}

我查看了剑道代码并注意到有两次调用事件的动作是"添加"。

任何可能导致ObservableArray触发事件/动作的提示"添加"两次?

0 个答案:

没有答案