我有一个集合,我正在根据这样的属性获取模型
var coll=reportWidgets.where({"is_editing":true});
我想循环访问这些模型并将属性 is_editing
设置为 false。
我该怎么做?
最佳答案
_.each(reportWidgets.where({is_editing: true}), function (reportWidget) {
reportWidget.set('is_editing', false);
});
使用类似于@nikoshr的_.invoke
的替代方案
_.invoke(reportWidgets.where({is_editing: true}), 'set', 'is_editing', false);
关于javascript - 循环遍历主干中的阵列模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23157854/