J
J
jww2018-03-26 21:48:30
JavaScript
jww, 2018-03-26 21:48:30

How to call different JS code when opening modal windows?

Good day. There are several standard Bootstrap modal windows, called by pressing buttons, how to make it so that when one modal window is active, one JS script is executed, when another, another script.
And the problem is that the script would be executed not only at the time of the "click", but while the modal window is open.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2018-03-26
@bootd

Take advantage of the event

$('#exampleModal').on('show.bs.modal', function (event) {
console.log($(this))
})

or open each window with js
$('#exampleModal')
.modal('show')
.on('show.bs.modal', function (event) {
console.log($(this))
})

Did you read the Doc at all?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question