Skip to content

Commit 6b41cf6

Browse files
authored
Merge pull request #944 from swierczek/must-interact-modal
Must interact modal
2 parents 79b5dac + 2a8586d commit 6b41cf6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/development/services/modal.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,23 @@ Now when a user selects some content in the table, the bulk action controls shou
132132

133133
## Advanced functionality
134134

135+
### Required interaction
136+
137+
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.
138+
139+
$modal_vars = array(
140+
'name' => 'hello must-interact',
141+
// ... other settings
142+
);
143+
$modal_html = ee('View')->make('ee:_shared/modal_confirm_delete')->render($modal_vars);
144+
145+
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.
146+
147+
$('.modal-wrap .dialog__buttons button').on('click', function() {
148+
$(this).closest('.must-interact').removeClass('must-interact');
149+
$(this).closest('.modal').trigger('modal:close');
150+
});
151+
135152
### Automatically open a modal
136153

137154
If you manually build a modal view, you can add `.app-modal` and a `rev` attribute like:

0 commit comments

Comments
 (0)