当我在集合中监听模型的布尔属性的更改事件时,如何处理事件以切换以在集合中的所有其他模型上关闭bool。
答案 0 :(得分:0)
试试这个:
// in your model
yourModel.on('change:yourBooleanAttribute', yourCollection.setAllButCurrent);
// and in your collection
setAllButCurrent: function(changedModel, value, options) {
// here you can iterate through `this.models` and for each model
// if it's `id` differ from changedModel id, change it's `yourBooleanAttribute`
// to the opposite value of `value`
}