【问题标题】:Transfer data from html-forms by mail in meteor.js在meteor.js中通过邮件从html-forms传输数据
【发布时间】:2014-12-25 21:41:13
【问题描述】:

如何从meteor.js 中电子邮件模板正文中的html-forms 传输数据?文档就是一个例子:

Meteor.call('sendEmail', 'alice@example.com', 'bob@example.com', 'Hello from Meteor!', 'This is a test of Email.send.');

但它确实只通过字符串值传达提前。如何从表单中传输数据?

【问题讨论】:

    标签: javascript email meteor forms


    【解决方案1】:

    你可以这样做

    values = {
        nick: $('#nick').val(),
        message: $('#your-message').val()
    }
    

    并调用类似的方法

    Meteor.call('sendEmail',
                'alice@example.com',
                'bob@example.com',
                'Hello from Meteor!',
                values); 
    

    并且在服务器上的方法中

    Meteor.methods({
      sendEmail: function (to, from, subject, text) {
    
        Email.send({
          to: to,
          from: from,
          subject: subject,
          text: 'Hello '+text.nick+'. Your message was: '+text.message
        });
      }
    });
    

    【讨论】:

      猜你喜欢
      • 2017-02-03
      • 2013-11-10
      • 1970-01-01
      • 2015-05-25
      • 2017-01-28
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 2017-11-16
      相关资源
      最近更新 更多