GithubHelp home page GithubHelp logo

Bootstrap not working about importmap-rails HOT 3 CLOSED

rails avatar rails commented on August 11, 2024
Bootstrap not working

from importmap-rails.

Comments (3)

guybedford avatar guybedford commented on August 11, 2024

@omairrazam Bootstrap as imported there is a "script" not a "module". In modules, the this binding is not the global object but undefined, so this.bootstrap = Bootstrap fails.

Either load that file as a script, or use a version of Bootstrap that works as a module. For example via a module CDN which can handle this conversion process.

from importmap-rails.

ianneub avatar ianneub commented on August 11, 2024

@omairrazam I had some issues getting bootstrap and popper working with Rails 7.0.0.alpha2, finally fixed them by changing the relevant entries in ./config/importmap.rb to:

pin "bootstrap", to: "https://ga.jspm.io/npm:[email protected]/dist/js/bootstrap.esm.js"
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/[email protected]/dist/esm/index.js"

edit: those are newer versions of Bootstrap and Popper. I'm not sure if Bootstrap has an ESM ready version for 4.0.0.

from importmap-rails.

bensheldon avatar bensheldon commented on August 11, 2024

@ianneub Do dropdowns work when you import the esm version of Bootstrap? I am only successful when pinning the bundle version that includes Popper, e.g.:

pin "bootstrap", to: "https://ga.jspm.io/npm:[email protected]/dist/js/bootstrap.bundle.min.js"

Bootstrap's docs seem to imply that the dropdowns don't work for the esm version:

Due to browser limitations, some of our plugins, namely Dropdown, Tooltip and Popover plugins, cannot be used in a <script> tag with module type because they depend on Popper. For more information about the issue see here.

from importmap-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.