1
How to recognize button/element click inside a modal window?
I tried the following, without success:
$("#modalEscolha").bind('click', function () {
if ($("#escolherComp").data('clicked')) {
alert("Componente!");
} else if ($('#escolherKIT').data('clicked')) {
alert("KIT!");
} else {
$('#acionamento').prop('selectedIndex', 0);
}
});
Editing:
I own a input select
, which must be set according to the closing of the modal or the clicking of the buttons: escolherComp
or escolherKIT
. If the user closes the modal, or by clicking outside the body, or the close button, the index 0
should be set, otherwise if any of the buttons click occurs the set option should remain (no action is executed).
Have you tried using . on instead of . bind?
– Sam
Hello @Dvd, not solved.
– lucasbento
From what I understand, your question would be "How to set index 0 in the element
$('#acionamento')
when the modal is closed?".. Would this be?– Sam
@DVD, yes and when none of the buttons are clicked.
– lucasbento
What are these buttons?
– Sam
#escolherComp
and#escolherKIT
@Dvd– lucasbento
Try changing only the first line to
$("#modalEscolha, #modalEscolha input").on('hidden.bs.modal click', function () {
.– Sam
Let’s go continue this discussion in chat.
– lucasbento
Why don’t you post the HTML?
– user60252
HTML is "huge". https://pastebin.com/hETWM3vq
– lucasbento