Creating an ‘on-click’ trigger inside a modal can be tricky.
Suppose, I have written a code to delete a page. To confirm I like to show a modal popup whether the user really wants to delete the page ? Without accepting if I close it and then decide to delete the another one and accidentally delete both of the pages ? LOL, it has actually happened with me.
This can be easily fixed.
For the onclick trigger use the following method only. I am using it for Bootstrap 4.5
1 2 3 |
jQuery('#MyModal').on('click', '.delete', function(e) { // write your code }); |
This really fixed my issue of double clicking event that was getting called.
Hope it helps you too.