I find this approach useful:
Create click event:
$( button ).on('click', function(e) {
let id = e.node.data.id;
$('#myModal').modal('show', {id: id});
});
Create show.bs.modal event:
$('#myModal').on('show.bs.modal', function (e) {
// access parsed information through relatedTarget
console.log(e.relatedTarget.id);
});
Extra:
Make your logic inside show.bs.modal to check whether the properties are parsed, like for instance as this:
id: ( e.relatedTarget.hasOwnProperty( 'id' ) ? e.relatedTarget.id : null )