I have this button in an HTML file and the following JavaScript in a JS file:
<button class="btn btn-primary" name="btnFeedback" onclick="sendEmail()">Submit</button>
function sendEmail() {
alert("Hello");
}
but the alert will not run when I click on the button. I receive, sendEmail is undefined. Here is the whole project where I have the code. The JavaScript file is in app/main.js
https://github.com/csergent45/streetSigns
Solved! Go to Solution.
In general its best to avoid using event attributes. Instead try using dojo/on to hook up the click event. So your code would look like this instead:
on(dom.byId("idForYourButton"), "click", function(){ sendEmail(); });
In general its best to avoid using event attributes. Instead try using dojo/on to hook up the click event. So your code would look like this instead:
on(dom.byId("idForYourButton"), "click", function(){ sendEmail(); });
Thanks for the Event attributes sample.