javascript - Pass ID into Bootstrap Modal? -
how pass id <button>
bootstrap modal. can use id information ajax display in modal.
for example:
button:
<button id="123" type="button" class="btn btn-sm" data-toggle="modal" data-target="#testing">edit</button>
should use shown.bs.modal
this?
$("#testing").on('shown.bs.modal', function () { // how id? id="??" //ajax });
you can use event
object passed show.bs.modal
handler.
$('#testing').on('show.bs.modal', function (event) { var id = $(event.relatedtarget).attr('id'); });
event.relatedtarget
refers button has triggered modal open event.
Comments
Post a Comment