Add 'leave.bs.tab' event
Created by: mtarnovan
If the event of leaving a tab needs to be captured, the only way to do this at the moment is to check relatedTarget
on show/shown events. A typical use-case would be checking if a form contained in a tab has unsaved changes to show a warning to the user when we switches to another tab. So instead of code like this:
$('a[data-toggle="tab"][href="#my-tab-with-form"]').one('leave.bs.tab', checkDirty)
we have to do something like this:
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
if ($(e.relatedTarget).attr('href') == '#my-tab-with-form') {
return checkDirty();
}
})
This also means that there's no way to only bind this once, because we emulate the leave event by checking the relatedTarget
on show/shown.