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
– Ricardo Pontual
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>
– Diego Laura Soares
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
– Diego Laura Soares
Possible duplicate of Modal within a modal
– adventistaam
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 thedata-dismiss
and call a Function that runs something like$('#idDaSegundaModal').modal('hide')
– Ricardo Pontual
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.
– Diego Laura Soares