0

我有两个视图在我的集合中监听不同的事件。

this.cartCollection.on('quantityAdded', this.QuantityAdded, this);          
this.cartCollection.on('quantitySubtracted', this.QuantitySubtracted, this);
this.cartCollection.on('salesPriceRateUpdated', this.UpdateCartItemPrice, this);
this.cartCollection.on('unitMeasureUpdated', this.ChangeItemPriceOnUnitMeasure, this);
this.cartCollection.on('warehouseCodeUpdated',this.ChangeItemPriceOnWarehouseCode,this)
this.cartCollection.on('quantityOrderedUpdated', this.UpdateCartItem, this);
this.cartCollection.on('quantityDefectiveUpdated', this.UpdateCartItem, this);
this.cartCollection.on('discountUpdated', this.UpdateCartItem, this);       
this.cartCollection.on('discountAppliedToAll', this.ApplyDiscountToAll, this);

this.cartCollection.on('clearedTransaction', this.VoidTransactionWithValidation, this)

在 maintemplate.js 我有这个

this.collection.bind("add", this.ModelAdded, this);         
this.collection.bind("change", this.ModelChanged, this);
this.collection.bind("viewDetails", this.ShowItemDetails, this);
this.collection.bind("viewFreeStock", this.ShowFreeStock, this);
this.collection.bind("viewAccessory", this.ShowAccessory, this);
this.collection.bind("viewSubstitute", this.ShowSubstitute, this);
this.collection.bind("itemRemoved", this.RemoveItem, this);
this.collection.bind("reset", this.ReinitializeCart, this);

但是在我的模板上,这些事件来自我的模型,该模型链接到我的收藏。触发后this.cartCollection.on('salesPriceRateUpdated', this.UpdateCartItemPrice, this);

当我触发this.UpdateCartItemPrice' 不再捕获任何事件时,我正在更新集合,this.cartCollection.reset然后在此之后传递更新的模型。我什至尝试添加相同的结果。this.cartCollection.add(data)salesPriceRateUpdated maintemplate{merge:true}

关于如何正确保留事件绑定的任何想法?谢谢

4

0 回答 0