Reputation: 537
Using meteor 0.5.7 - following the Parties example - made client, server folders, and placed respective client.js and server.js files in them. I have autopublish, insecure removed, and added email package. I can't get the Meteor.call to fire off, debugging shows that it gets bypassed, I'm loosely following this - http://goo.gl/MV26m - and I still don't understand.
// server.js
Meteor.startup(function () {
process.env.MAIL_URL = '...'; // using mailgun URL
});
Meteor.methods({
call_me: function (options) {
var options = options || {};
Email.send({
from: options.from,
to: options.to,
replyTo: options.from || undefined,
subject: options.subj,
text: options.msg,
});
},
});
// client.js
Template.form.events({
'click .submit' : function (event, template) {
var from = template.find("#from").value;
var to = template.find("#to").value;
var subj = template.find("#subj").value;
var msg = template.find("#msg").value;
var options = { from: from, to: to, subj: subj, msg:msg };
Meteor.call('call_me', options, function(err, data) {
if (err)
console.log(err);
});
}
});
// client.html - the gist of it
<body>
{{> page }}
</body>
<template name="page">
{{> form }}
</template>
<template name="form">
<form ....
</template>
Lastly, I actually had the Meteor.methods({...}); sitting in a model.js file outside the client/server folders - and it still didn't fire off emails, or invoke the Meteor.call method. I'm kinda trying to wrap my head around the notion of a stub in the aforementioned attached link, wrapped the call within a function and called it, and I still didn't get any activity. Thanks for any advice.
Upvotes: 2
Views: 828
Reputation: 1825
Tried your gist. Removing the <form>
tag and commenting out Process.env.MAIL_URL
did it. The <form>
tag is blocking the event trigger to button click.
Upvotes: 1