Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #14768
Closed
Open
Issue created Oct 10, 2014 by Administrator@rootContributor

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.

Assignee
Assign to
Time tracking