Correct way to add an ‘on click’ event on a bootstrap 4 modal

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

This really fixed my issue of double clicking event that was getting called.

Hope it helps you too.

Leave a Reply

Your email address will not be published. Required fields are marked *