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

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.

Join the discussion

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

Join 53,130+ 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.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.