【发布时间】:2014-05-26 20:09:14
【问题描述】:
我正在使用以下内容创建新用户:
Accounts.createUser({
username: t.find('#username').value,
password: t.find('#password').value,
email: t.find('#email').value,
profile : {
name: t.find('#name').value,
division: 'none',
enrolled: 'false'
}
});
当用户从下拉选择中选择时,我需要能够更新部门字段。这是我的模板:
<template name="userProfile">
<p>Select your division</p>
<select id="division">
<option>Div1</option>
<option>Div2</option>
<option>Div3</option>
<option>Div4</option>
</select>
<button id="enrolled"> Not enrolled </button>
<p>a: {{currentUser.profile.name}}</p>
<p>b: {{currentUser.profile.division}}</p>
</template>
我有一个有效的点击事件,但我不知道如何在配置文件中附加或修改字段:
Template.userProfile.events({
'click #division': function(e, t) {
console.log('Selected division is: ', t.find('#division').value);
Meteor.user.profile.division = t.find('#division').value;
},
'click: #enrolled': function(e, t) {
console.log('User is enrolled? : ');
}
});
我希望当用户选择一个部门时,当前用户的个人资料中的字段会更新。
我还有一个问题,但我会把它放在一个单独的线程中。
谢谢。
【问题讨论】: