我想在会话中使用 userId ...能够保存用户的名字和所有内容...
我正在尝试静脉使用 models.add("users."+userId) 静脉......
app.proto.editUser = function(){
var userId = this.model.get('_page.userId');
//I get d0514d00-da58-3074-b013-e075a772740c
console.log(userId);
this.model.add('users.'+userId,{
'firstName':this.model.get('_page.firstName'),
'lastName':this.model.get('_page.lastName')
});
var user = this.model.at('users.'+userId);
this.model.set('users.'+userId+'.firstName', this.model.get('_page.firstName'));
}
这确实尝试将 firstName 设置两次,但即使将另一个注释掉也不起作用....我通常会收到有关回滚的错误。
HTML:
<index:>
<h2>Account Information</h2><br/>
User Id: {{_page.userId}}<br/>
First Name: {{_page.firstName}}<br/>
Last Name: {{_page.lastName}}<br/>
<br/>
<form class="form-horizontal" on-submit="editUser()">
<div class="row">
<div class="col-lg-6 col-sm-12">
<div class="form-group">
<label for="inputFirstName" class="col-sm-3 control-label">First Name</label>
<div class="col-sm-9">
<input type="text" value="{{_page.firstName}}" class="form-control" id="inputFirstName" placeholder="First Name">
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="form-group">
<label for="inputLastName" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input type="text" value="{{_page.lastName}}" class="form-control" id="inputLastName" placeholder="Last Name">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-sm-12">
<div class="form-group">
<label for="inputGender" class="col-sm-3 control-label">Gender</label>
<div class="col-sm-9">
<select class="form-control" id="inputGender" name="gender">
<option value="none">None</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</div>
</div>
</div>
<div class="col-lg-6 col-sm-12">
<div class="form-group">
<label for="inputAge" class="col-sm-3 control-label">Age</label>
<div class="col-sm-9">
<input type="number" class="form-control" id="inputAge" placeholder="Age">
</div>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<button type="submit" class="btn btn-success">Update</button>
</div>
</div>
</div>
</form>
错误往往是:
操作错误:计划收集用户中的操作无效 d0514d00-....
其他人似乎都在按照我想的那样做......我是否总是需要检查一个是否存在并且只在存在时才使用 add ?
这一切都在derby0.6中