Last active
May 1, 2016 23:17
-
-
Save bretth18/1e16dae698904583d310f9eb1e396e95 to your computer and use it in GitHub Desktop.
medium-3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onSubmit(e){ | |
// grab form elements using jquery... i think there's a better way for this. | |
e.preventDefault(); | |
var element = $(e.target); | |
var firstName = element.find("#firstName").val(); | |
var lastName = element.find("#lastName").val(); | |
var emailVal = element.find("#emailVal").val(); | |
var companyVal = element.find("#companyVal").val(); | |
var messageVal = element.find("#messageVal").val(); | |
// create object to pass to our server method | |
var subForm = { | |
first_name: firstName, | |
last_name: lastName, | |
email_val: emailVal, | |
company_val: companyVal, | |
message_val: messageVal, | |
}; | |
// call server side sparkpost code to send email from form input | |
// current state variables need to be called in this function referencing state of component | |
Meteor.call('sendEmail', subForm, function(err){ | |
if(err){ | |
console.log("error", error); | |
Materialize.toast('An error occured while sending your message: ' + error); | |
} else { | |
// console.log('it worked'); | |
Materialize.toast('Message sent!', 4000); | |
FlowRouter.go('/contact'); | |
} | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment