dsilver829
dsilver829

Reputation: 295

Debug jQueryUI Versions in Rails

Within my Rails project, my old jQuery code for sorting a list of <li> elements has broken. The logged error is:

TypeError: $.ui.isOverAxis is not a function

I think the culprit is that an unwanted, older version of jquery-ui.js (v1.9.2) is making it into my headers, and I don't know how to remove it.

The unwanted jQuery file is originating from the jquery-rails gem. I don't understand why, since I've removed the //= require jquery-ui line from my application.js file.

Here is my current application.js file:

//= require moment.min.js
//= require nicEdit.js
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require_tree .

My Gemfile is updated to the most recent versions of the jquery-rails gem (2.2.1) and the jquery-ui-rails gem (4.0.3).

Yet an older version of jquery (1.9.2) appears in my header files in development mode:

<script type="text/javascript" src="/assets/jquery-ui.js?body=1"></script>

Through debugging in development mode, I can tell that the jquery-ui.js file comes from the jquery-rails gem.

Any suggestions on how to fix this?

UPDATE

I have updated the question to reflect my discovery that the jquery-ui.js file is, in fact, coming from the jquery-rails gem.

Upvotes: 0

Views: 1268

Answers (1)

dsilver829
dsilver829

Reputation: 295

It appears that ActiveAdmin is calling //= require jquery-ui, which is in turn pulling in the jquery-ui.js file from jquery-rails.

That file is clobbering the version of jQueryUI from jquery-ui-rails.

The long-term solution might be for jquery-rails to remove the jquery-ui.js file, or at least rename it.

In the short-term, I solved my problem by removing //= require jquery.ui.all and relying entirely on jquery-rails, skipping jquery-ui-rails altogether.

Upvotes: 1

Related Questions