0
Schemas = {};
Schemas.ContactForm = new SimpleSchema({
name: {
type: String,
label: "Your name",
max: 50
},
email: {
type: String,
regEx: SimpleSchema.RegEx.Email,
label: "E-mail address"
},
message: {
type: String,
label: "Message",
max: 1000
}
});
HTML:使用Meteor Autoform'meteormethod'屬性回調?
<template name="contactForm">
{{#autoForm schema=Schemas.ContactForm id="contactForm" type="method" meteormethod="sendEmail"}}
<!-- etc. -->
{{/autoForm}}
</template>
流星方法,請檢查意見:
Meteor.methods({
sendEmail: function(contents){
check(contents, Schemas.ContactForm);
Mandrill.messages.send({
// do something to send
}, function(error, response){
if (error){
// how does error bubble back up to the client?
} else {
// how does success bubble back up to the client?
}
})
},
})
因此,使用了自動meteormethod
屬性,我怎麼得到錯誤或從我的服務器調用響應Mandrill可以向客戶回報,以便我可以通知用戶表單已成功提交併通過電子郵件發送。
只需在AutoForm上不使用meteormethod
屬性,並手動在表單提交上連接Meteor.call
來更好嗎?