【发布时间】:2017-02-06 21:11:54
【问题描述】:
你好朋友们可以指点我一些材料,比如修改密码、电子邮件和在个人资料中添加新字段,如性别、年龄城市添加照片。不使用集合或 aldeed-autoform。 所有这些都是用我自己的代码完成的,因此对一些 alded-autoform 选择功能(如 select 或 datepicker)进行更多控制在设计中看起来并不好。
Template.update.events({
'submit form' ( event, template ) {
event.preventDefault();
const target = event.target;
var oldPass = $('#password');
var newPass = $('#password-new');
var verifyPass = $('#password-confirm');
if(newPass.val() === verifyPass.val()){
Accounts.changePassword(oldPass.val(), verifyPass.val(), function(err){
if(err) {
console.log(err);
} else {
let profile = {
address: {
city: target.city.value,
street: target.street.value
},
gender: target.gender.value,
favoriteColor: target.favoriteColor.value,
}
console.log("datos actualizados");
}
});
oldPass.val('');
verifyPass.val('');
newPass.val('');
} else {
console.log("password no match");
}
//}
console.log(profile);
Meteor.call('updateUser', profile);
}
});
{
_id: "bbca5d6a-2156-41c4-89da-0329e8c99a4f",
emails: [
{ address: "cool@example.com", verified: true },
],
createdAt: Wed Aug 21 2013 15:16:52 GMT-0700 (PDT),
profile: {
name: "Joe Schmoe",
phone: "5555-555-555",
gender: "male",
city: "DC",
country: "USA",
birthday: "01-01-2017"
}
【问题讨论】:
-
您可以创建自己的“组件”来使用 autoform,您不必依赖它们的默认组件。
-
你能告诉我如何做一些文档吗? @zim
-
文档在这里:github.com/aldeed/meteor-autoform#defining-custom-input-types,如果有帮助,我可以用一些示例代码发布答案
标签: javascript meteor meteor-blaze meteor-accounts