Skip to content

Must interact modal #944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 7.dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/development/services/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ Finally, we need to create our Bulk Action Controls with some special data attri

Now when a user selects some content in the table, the bulk action controls should appear, and when "Remove" is selected and submitted, a modal will appear showing a list of content about to be deleted, where they can then confirm the deletion and your `POST` handler will be fired.

## Advanced functionality

### Required interaction

By default, clicking the close button, the escape key, or anywhere outside of the modal will close it, acting similar to cancelling the action the modal was prompting for. But if you want to prevent this default behavior and instead want to require the modal to be interacted with, you can add the `must-interact` class as part of the `name` parameter.

$modal_vars = array(
'name' => 'hello must-interact',
// ... other settings
);
$modal_html = ee('View')->make('ee:_shared/modal_confirm_delete')->render($modal_vars);

NOTE: Note: you will also need to add custom JS to remove `.must-interact`, and then trigger the `modal:close` event in order to close it.

$('.modal-wrap .dialog__buttons button').on('click', function() {
$(this).closest('.must-interact').removeClass('must-interact');
$(this).closest('.modal').trigger('modal:close');
});

## CP/Modal Service Methods

**class `ExpressionEngine\Service\Modal\ModalCollection`**
Expand Down