All threads / Rails6 - how to make jquery available in chrome console?
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?

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

window.$ = window.jQuery = require("jquery")
Join the discussion

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

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

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

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.