bootstrap-modal: event.relatedTarget undefined
Seems like event property relatedTarget gets lost. It would be nice to keep bs3 documented functionality intact. Maybe I overlooked something… (?)
$('#modal').on('show.bs.modal', function (e) {
var invoker = $(e.relatedTarget);
console.log(invoker); //undefined when bootstrap-modal included
});
About this issue
- Original URL
- State: open
- Created 10 years ago
- Reactions: 2
- Comments: 22
I appreciate this is anold post but I found this colustion worked for me.
$(event.relatedTarget).attr('data-whatever')
A quick note: e.relatedTarget is available when the modal is opened with the data-toggle and data-target attributes in the link/button calling the modal. (tested with bootstrap button calling the modal)
Instead is not available when the modal is opened via jquery ($(‘#myModal’).modal("show)
you must be missing the event argument on handler
$('#myModal').on('show.bs.modal', function (THIS ONE HERE: event) { ... });
Hi. I’ve found the way to grab the data-variable from modal.
var options = modal.data().modal.options;
This will return ALL the data-* (so look for key-dup)
I have the same problem with