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.

bootstrap documentation


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -