Is `require jquery_ujs` still needed in Rails 5.1?

I am installing jQuery in my 5.1.xRails application using jquery-railsgem.

In gem configuration, it is recommended to put these lines in application.jsthe default:

//= require jquery
//= require jquery_ujs

But in a Rails application 5.1.x, you already have this line, which is no longer dependent on jQuery:

//= require rails-ujs

I believe that both do the same, and one is not needed.

Should I save both anyway, or should I use only jquery_ujsor only rails-ujs?

+5
source share
2 answers

jquery-ujs a thing of the past with Rails 5.1, you don’t need it.

+2
source

Rails 5.1 jQuery UJS ( javascript). jQuery rails,

//= require rails-ujs

, JQuery , jquery-rails , rails-ujs, :

//= require jquery
//= require jquery_ujs

jquery_ujs jQuery , JS:

Uncaught Error: jquery-ujs has already been loaded!

0

Source: https://habr.com/ru/post/1678907/


All Articles