Ask A Question

Notifications

You’re not receiving notifications from this thread.

Uncaught Error: If you load both jquery_ujs and rails-ujs, use rails-ujs only.

Tripscape asked in Javascript

I have a rails 6.1 application that uses jquery. Here is how I'm importing it in my config/webpack/environments.js file:

$: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery',
jquery: 'jquery',
'window.jQuery': 'jquery'

I am trying to use this the stimulus-sortable component from here:
https://stimulus-components.netlify.app/docs/stimulus-sortable/

Which causes this error: Uncaught Error: If you load both jquery_ujs and rails-ujs, use rails-ujs only.

I can resolve the error by either removing jquery entirely, or removing rails ujs from my application.js file.

It appears to be specific to the stimulus-sortable component, although I'm not sure what is causing that to throw this error, as I am not importing jquery-ujs.

Any help or advice would be greatly appreciated. At this point, I'm probably just going to write my own stimulus controller.

Reply
Join the discussion
Create an account Log in

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

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

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