Jake N
Jake N

Reputation: 10583

Twitter Bootstrap Modal, bind to close button and get clicked element

Using this I can do something when a modal is closed

$(".something").on('hidden.bs.modal', function (e) {
    alert("closed");
});

But the e event does not contain anything about the element that was used to close the modal. Granted it might not have been an element, it might have been a key or a click simply 'off' the modal. But I still want to know which element was clicked in order to hide the modal, if there was one.

Overriding the click event on the close buttons just stopped the modal closing correctly. It would disappear but the modal fade area was still present.

Any ideas?

Upvotes: 0

Views: 186

Answers (1)

calinaadi
calinaadi

Reputation: 1466

Have Bootstrap plugin events forward the underlying originalEvent that caused them is an Known isssue and it wil be included in v4.

Meanwhile you can check this alternative solutions:

https://github.com/twbs/bootstrap/issues/15408

bootstrap how to detect which button closed a modal dialog on 'hidden_modal_bs' event func?

Upvotes: 1

Related Questions