I have a JavaScript/jQuery application in which a Bootstrap Modal window is opened when any of the order cards in the image below are clicked on.
In the Modal HTML, I have a Start Timer Button
This timer button is added to the DOM after the DOM has already been loaded. SO I use this code below to attach a click event to the button after DOM loaded...
// Handle Timer Start Button click event
$(document).on('click', '.start-job-btn', function(e) {
console.log('start timer');
alert('start timer');
e.preventDefault(); // prevents default
return false;
});
HTML
<a href="#" data-order-id="5508" data-order-item-id="158" class="btn btn-primary start-job-btn">Start Job</a>
The Problem
When I click the start button I get my alert and console logger ran 3-6 times each button click!
I cannot figure out why this would happen as it doesn't happen in any other sections of the app. Just this button which has the code shown above.
It's hard to setup a demo app as the project is over 10k lines and would be hard to get it all up but based on this info does anyone have any ideas?


off()is my answer