我正在开发一个在线/离线应用程序,我注意到了这一点:
我从 localStorage 中获取我的离线检索。(每次用户在线登录时,我都会使用从我的服务器检索到的附加数据来保存他)
如果同一个用户现在尝试离线登录,我会检查此运算符是否与我的集合中的任何运算符匹配,如果它与条目匹配,则返回运算符匹配项。
问题是,我从 collection.get(#id) 获得的运算符没有来自骨干运算符模型的任何方法。
在更正我的代码之前是这样的:
if( this.isLocalValidOperator( operator ) ){
var operatorMatch = this.get(operator.get('id'));
cb( operatorMatch );
}
我的更正,现在可以了
if( this.isLocalValidOperator( operator ) ){
var operatorMatch = this.get(operator.get('id'));
// must add additional attributes from the match, then return the operator created with new Operator( someAttributes )
operator.set({
isSuperadmin: operatorMatch.get('isSuperadmin'),
isModerator: operatorMatch.get('isModerator'),
firstname: operatorMatch.get('firstname'),
lastname: operatorMatch.get('lastname')
});
cb( operator );
}
我究竟做错了什么 ?