Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap v4 and JSPM jQuery Dependency #19766

Closed
markhughes opened this issue Apr 20, 2016 · 3 comments
Closed

Bootstrap v4 and JSPM jQuery Dependency #19766

markhughes opened this issue Apr 20, 2016 · 3 comments
Labels

Comments

@markhughes
Copy link

Hello! I'm having some complications here..

I have both jQuery and bootstrap installed like so:

jspm install jquery
jspm install bootstrap=npm:[email protected] 

However, when I try to use it like so..

import $ from "jquery";
import "bootstrap"; // ... nothing will happen past this point 

// .. should be getting to this point and doing stuff ...

I get Uncaught Error: Bootstrap's JavaScript requires jQuery in my console when trying to use my website.

This is odd, as I use other jQuery plugins and they work fine with JSPM.

Here is my config.js file: http://pastebin.com/dEwS77an

Using JSPM 0.16.33

😄

@cvrebert
Copy link
Collaborator

Approximate duplicate of #19067.
This will get properly resolved once we use ES6 imports for jQuery in our modules, which falls under #19017.

@markhughes
Copy link
Author

I see. I've gotten halfway, however I'm still trying to work out what Tether exports as I cant seem to get it on the global scope.

Globals.js

import $ from "jquery";
import Tether from "HubSpot/tether";

global.jQuery = $;
global.Tether = Tether;

Main.js

import $ from "jquery";
// ... more imports here ... 
import "./Globals";
import "tether";
import "bootstrap";

// .. blah blah 

So this gets past the jQuery issue, however Tether is now required:
Uncaught Error: Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)

In console..

> window.jQuery
   (a,b){return new ga.fn.init(a,b)}
> window.Tether
   undefined

@markhughes
Copy link
Author

Never mind! I screwed around with it enough, and used window instead of global ..

Globals.js

import $ from "jquery";
import Tether from "HubSpot/tether";

window.jQuery = $;
window.Tether = Tether;

Main.js

import $ from "jquery";
import Tether from "HubSpot/tether";
import "./Globals";

// .. blah blah 

import Backend from "./Backend/Backend";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants