I've got it working in Codepen but for the life of me I cannot get it to work in Joomla as a module.
When I try to run the module in a set page, the modal does not appear and I get an error in the console saying that it can't find bootstrap function.
This module specifically triggers the modal after 1000ms instead of triggering through a traditional button.
View example in codepen: https://codepen.io/dsm/pen/mdgbwBY
I'm loading the script in like so and displays after bootstrap is loaded:
Code: Select all
$wa->registerAndUseScript('mod_nu_popup', 'modules/mod_nu_popup/tmpl/popupscript.js', [], ['type' => 'module'], ['core']);
Code: Select all
document.addEventListener("DOMContentLoaded", function (event) {
var myModal = new bootstrap.Modal(document.getElementById("nuModal"), {});
setTimeout(function () {
myModal.show();
}, 1000);
})
Code: Select all
<div class="modal fade numodal" id="nuModal" tabindex="-1" aria-labelledby="nuModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="popup-img">
<a class="d-block" href="<?php echo $popupUrl; ?>">
<img src="https://mysite.com/image.jpg" alt="alt text"/>
</a>
</div>
<p><a class="btn btn-primary" href="https://mysite.com">Visit Today!</a></p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
Thanks in advance!