Skip to content
Advertisement

Modal close button is not working despite the on() function

whenever I click my “show more” button my modal pops up however when I click my X button on the left corner it doesn’t close like I expect it to. It does respond to clicking outside of the box and the “esc” key.

I believe the issue is happening on modalClose.on() but everything looks fine to me.

Any suggestions as to why this might be happening?

JavaScript
JavaScript

Advertisement

Answer

Because for some reason the modal is being reconstructed I assume all the event handlers bootstrap configs for it are gone. So you want to catch click on close, you need to do that after it is shown. This can be done using the event bootstrap provides.

JavaScript

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement