So I am working on an application with a few friends and we are having trouble with an onclick function to send an email via sendgrid when using jade and coffeescript. The code is deployed to Heroku so we are using the example from the heroku devcenter to implement some functionality with sendgrid. I even had a console.log in the function earlier to see if it was being called but nothing was printed. Any ideas why this could be happening?
Here is the code in jade, the include for the js (our converted coffeescript) is down at the bottom. These bits of code are in different files. The coffeescript is in landingPage.coffee so it is included via a js include at the bottom of the jade code. Under the jade code is the coffeescript function. Any help is much appreciated.
#footer
.container
.row
.col-lg-8.col-lg-offset-2.text-center
h1 Now you can join our launch party!
form.ui.form.inverted.segment(style="background-color:#333333;" action='/api/intUser' method='post', id="validate", novalidate="novalidate")
.two.fields
.field
label First Name
input(type="text", placeholder="First Name", name="first")
.field
label Last Name
input(type="text", placeholder="Last Name", name="last")
.field
label Email
input(type="email", placeholder="Email@example.com", name="email", id="email")
input(class="ui blue submit button" type="submit" name="Submit" onclick="sendEmail()")
.ui.error.message
!= js('/js/landingPage')
Here is the coffeescript code for the sendEmail function
sendEmail ->
sendgrid = require('sendgrid')(process.env.SENDGRID_USERNAME, process.env.SENDGRID_PASSWORD);
sendgrid.send({
to: 'cashalyst@gmail.com',
from: 'testing@gmail.com',
subject: 'Hello World',
text: 'My first email through SendGrid.'
}, (err, json) ->
if (err)
return console.error(err)
console.log(json))