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

jquery not loading #616

Closed
vallard opened this issue Apr 24, 2020 · 4 comments
Closed

jquery not loading #616

vallard opened this issue Apr 24, 2020 · 4 comments

Comments

@vallard
Copy link

vallard commented Apr 24, 2020

Thanks for this cool template. I'm trying to make the navbar toggler work, I don't see jquery loading anywhere, which I think is necessary. Is there a way to add that in or check if its working? Seems to be so in yarn when I installed all dependencies. Just doesn't seem to be doing anything in the browser. Thanks for any pointers.

@jonnyeom
Copy link

jonnyeom commented May 5, 2020

The starter integrated the css portion automatically but it does not load js automatically.

What I did was

Require the jquery and popper.js libraries.

npm install jquery popper.js --save-dev

And then import them where I needed it. e.g.

import 'jquery/dist/jquery.min'
import 'popper.js/dist/popper.min'
import 'bootstrap/js/dist/util'
import 'bootstrap/js/dist/carousel'

I think the documentation could be updated to explain this.

@jaxx2104
Copy link
Owner

jaxx2104 commented Jun 3, 2020

@jonnyeom
Thank you for the polite explanation on my behalf.

@vallard
I think I'll put it in the README.

@jonnyeom
Copy link

jonnyeom commented Jun 3, 2020

@jaxx2104 Before you do, I found that the method I used above works during gatsby develop but not during gatsby build.
instead of that method, I am now using a gatsby-browser.js.

I simply created a gatsby-browser.js file at the root of the project, and added all of my js dependencies.

// Import all js dependencies.
import 'jquery/dist/jquery.min.js'
import 'popper.js/dist/popper.min'
import 'bootstrap/js/dist/util'
import 'bootstrap/js/dist/carousel'
import 'bootstrap/js/dist/dropdown'

All this does is import these dependencies on all gatsby pages.

Because these js utilities are used on most of my pages, I am okay with this.
But I with I could get individual imports of JS dependencies per component file working correctly.

@jaxx2104 jaxx2104 mentioned this issue Jun 5, 2020
6 tasks
@jaxx2104
Copy link
Owner

jaxx2104 commented Jun 5, 2020

@jaxx2104 jaxx2104 closed this as completed Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants