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
  • #12833
Closed
Open
Issue created Feb 24, 2014 by Administrator@rootContributor

Replacing or wrapping component constructor functions

Created by: michaek

Bootstrap components are defined as constructor functions in a private scope. While they are exposed globally within $.fn, they are called with references to those constructors within that private scope.

That means that there's no way to replace or wrap the code within the constructor function from 3rd party code. The use case that I'm imagining: modifying the behavior of the stock components without maintaining a fork of Bootstrap.

The design that seems appropriate is moving the code from within the constructor functions into an init method on the constructor's prototype, leaving all constructor functions looking something like this:

var Affix = function (element, options) {
  this.init(element, options);
}

That would allow global access to override the init method, via $.fn.affix.Constructor.init which would also affect the reference to the constructor as Affix within its private scope. The change should not affect any functionality or the API beyond exposing the constructor function for manipulation. If this sounds good, I'll be happy to make a PR.

I apologize if this is revisiting an old question that's been resolved - I wasn't able to find historical work on this, but I know that doesn't mean it's not out there!

Assignee
Assign to
Time tracking