Ask A Question

Notifications

You’re not receiving notifications from this thread.

Rails6 - how to make jquery available in chrome console?

ConfusedVorlon asked in Rails

I'm new to rails 6, webpack, etc
It's working for me in my app and jquery is loaded (thanks for the intro @Chris)

However - although jquery works correctly in all my loaded js, I can't use it to experiment in the chrome console.

Presumably this is because webpacker is 'being a good citizen' and not polluting the global namespace with $

however - it's really annoying not to be able to test thigns in the console without jquery. How do I override the default and just make $ global?

Reply

You can just assign it to the window variable so it's accessible anywhere I believe.

window.$ = window.jQuery = require("jquery")
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.