How to add confirmation to Editor buttons?
How to add confirmation to Editor buttons?
Is there a way to add second confirmation to Editor's Create or Submit buttons? So users confirm they really want to create or edit record.
I am using BS5 version of Editor, so I have tried using BS modal to show confirmation message and OK/Cancel buttons. The problem is that Editor is BS modal itself, so my new modal is not clickable.
If I change z-index of .modal.DTED to be under my modal (e.g. to 1051), my dialog works. The problem is that each modal dynamically creates it's own backdrop with the same z-index 1050. So the z-order is like this:
Confirmation modal
Editor modal
Backdrop
Backdrop
There is no way to distinguish which backdrop is which. I need to get to this:
Confirmation modal
Backdrop
Editor modal
Backdrop
I understand that BS oficially supports only one modal at a time, but it seems that manipulating z-index for modal and backdrop should work. Any ideas?
Answers
As you say, Bootstrap can only show a single model at a time. I've not yet found a way around that.
There isn't currently a build in option in Editor to confirm a create or edit action. The delete action is has a confirmation button itself. Currently the only way to do it would be to use the
buttons
for the form and provide a function that will check with the user if they want to confirm the action. A simpleconfirm()
will do that, although it isn't a particularly attractive UI. When confirmed callsubmit()
.Thinking about it, I suppose there is one other option - needing to click the submit button twice. What you could do is have a
preSubmit
event handler that will check a hidden value to see if it is the first click or second. If the first, then usemessage()
/error()
to show a message that says "Click submit again to confirm" and set the value. Then the second submit will see the value is set and allow it to continue.Allan
Thanks Allan.
As you say javascript
confirm()
is foolproof but ugly solution.I have played a little bit with bs modal
z-index
and found a workaround, if anybody's interested. Use with caution, it's not guaranteed to work with future BS versions:Add some css:
Create and show modal:
I am using
data-bs-backdrop="static"
, not sure what would happen with different backdrop type.Awesome - thanks for posting back with your solution
Allan