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
  • Merge requests
  • !5318

Use .triggerHandler() instead of .trigger() for custom events.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/jschr/master into 2.1.2-wip Sep 27, 2012
  • Overview 0
  • Commits 6
  • Pipelines 0
  • Changes 6

Created by: jschr

For custom events (hide, show, closed, etc..) it is more desirable to not propagate the event by default. This causes many problems with nested components such as tabs within tabs or tabs within modals, etc.

The reason this is problematic is if I am watching the shown event on a modal that has tabs inside, clicking on the inner tab will cause the modal to receive a shown event. This fiddle shows the issue. Opening up the console will show that clicking on a tab triggers the modal's shown event as well.

The solution is to call stopPropagation() on the event which could be done in the event handler itself but this can automatically be done with the triggerHandler function instead of trigger. I can't think of a good use case why you would want these events to propagate through the DOM as it will almost always cause undesired behaviour.

See this jquery issue as a reference: http://bugs.jquery.com/ticket/10699

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/jschr/master