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

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -