modal on top of another modal without accepting each other’s shortcut

Asked

Viewed 52 times

0

I have a modal, which opens another modal, so far so good, I put a shortcut Ctrl+alt+c to cancel, so far so good, only I want that when I open the second modal, and click on the shortcut only it closes and not both, is possible???

this is my j

    $(document)
        .on(
                'keydown',
                function(e) {

                    if (e.ctrlKey && e.altKey
                            && e.which === 67) {
                        document.getElementById(
                                "btnCancelar").click();

                    }
if (e.ctrlKey && e.altKey
                        && e.which === 67) {
                    document.getElementById(
                            "btnCancelar1").click();

                }
    }); 

and with that I only put the id in my html. if anyone can help me??

cancel from modal 1

<button style="color: black;" type="button" class="btn btn-default" ng-click="limparCampos();" data-dismiss="modal" id="btnCancelar">Cancelar</button>

cancel from modal 2

<button style="color: black;" type="button" class="btn btn-default" data-dismiss="modal" id="btnCancelar1">cancelar</button>
  • how is the code of btnCancelar

  • this is from the first modal <button style="color: black;" type="button" class="btn btn-default" ng-click="cleanCampos();" data-Dismiss="modal" id="btnCancelar">Cancel</> and this is from the second modal <button style="color: black;" ="button" class="btn btn-default" data-Dismiss="modal" id="btnCancelar1">cancel</button>

  • and yes has another function if (e.ctrlKey && e.altKey && e.which === 67) { Document.getElementById( "btnCancelar1"). click(); } for the second button plus the shortcut and the same

  • 1

    Possible duplicate of Modal within a modal

  • Your button has the attribute data-dismiss="modal", which will close all open modals. If you want to close only one you must implement a code that does this.. the second modal may for example not term the data-dismiss and call a Function that runs something like $('#idDaSegundaModal').modal('hide')

  • even to do this, and the shortcut Ctrl+alt+c be the same for the two, which in this case is how I need it, it will close the two, had already tried it, that another time in other cases had happened to me and this Cod helped me more now I do not know what to do because being in js with id or class or anything else, if they have the same function they will continue to close together.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.