Shor hide a modal popup
I've got a Bootstrap modal that displays on page load and the content is updateable in a CMS section editor but I want to be able to show or hide the modal depending on when we want it to show. How can I do that with a checkbox, the Bootstrap styling that controls if it displays is .modal-open so to hide it I need to get rid of that styling but preferably with a checkbox.
I do this pretty regularly. Just create a check box such as "Show Modal", then wrap it in an if statement. If the checkbbox isn't ticked, there's no modal to display. As far as I'm aware, it doesn't matter that you still have the script trying to run it.
<?php if ($record['display_alert']): ?> <div class="modal fade" id="exampleModal"> ... </div> <?php endif ?>
<?php if ($pop_up_notificationRecord['show_modal'] == "1"): // checked ?>
<?php else: // not checked ?>
<?php endif ?>