Hook into controller formAfterSave and eventually show modal window

Is there an easier way to hook into controller formAfterSave and eventually show modal window, than following?

In my controller I have:

public function formAfterSave($model)
        if ($something === true) {

And then in my controllers update.htm I have my modal markup just at the end of everything else:

<div class="control-popup modal fade" id="my-modal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">
                <button type="button" class="btn-close" data-dismiss="modal"></button>
            <div class="modal-body">
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">

Then in my script.js I just have:

if ($('#my-modal').length) {

Hey @maki3000

This looks like a good use case for dispatching a browser event:

Here is an example that listens for the app:password-confirming event and displays a popup:

Triggered by

1 Like