I have the following code snippets in my main.js file
function one(){
//some code
var btn = "<button type='submit' id='processReceipt' class='btn btn-primary' onclick='form_new_receipt()'>Submit</button>";
document.querySelector('#showGrower').innerHTML += btn;
}
The function the submit button is calling is below
$(document).ready(function() {
// Do your event binding in JavaScript, not as inline HTML event attributes:
$("#processReceipt").on("click", form_new_receipt);
function form_new_receipt() {
alert('before function');
}
});
What could I be missing because the alert does not show up - meaning the function is not being called.
I had tried this below but it didn't work - that's why I added the $(document).ready
function form_new_receipt() {
alert('before function');
}