trongate / trongate-framework

The Trongate PHP framework
https://trongate.io
Other
1.11k stars 100 forks source link

Added modalClosed event to the closeModal() functions in admin.js and… #180

Closed domsinclair closed 2 months ago

domsinclair commented 3 months ago

… app.js

Realised that it would be incredibly useful to be able to respond to the inbuilt Trongate Modal closing, but in order to do that it needs to emit an event. This change provides that event and does so for people using both the public and or admin templates.

It requires that you actively subscribe to the event as early as possible. Below is a good example of how to do so;

  document.addEventListener('DOMContentLoaded', function () {
        document.addEventListener('modalClosed', function (event) {
            // Place your additional logic here

        });
    });

This means that you can now trigger additional functionality when a modal is closed. Useful for anyone who needs it and will have zero impact on anyone who doesn't.