Nazar Hussain
Nazar Hussain

Reputation: 5162

Rails 3.1, jQuery UI does not load

I am using Rails 3.1 and having an issue with the jQueryUI library. Here is my application.js file:

//= require jquery
//= require jquery-ui
//= require jquery_ujs
// Loads all Bootstrap javascripts
//= require bootstrap
//= require rails.validations

//= require_tree .

It loads the "jquery ui" file into the browser, but whatever I use related to it it shows this error:

TypeError: Object function (a,b){return new d.fn.init(a,b,g)} has no method 'dialog'

Upvotes: 5

Views: 2630

Answers (3)

Nazar Hussain
Nazar Hussain

Reputation: 5162

After hours of struggling with the issue, I finally removed //= require jquery-ui from application.js and added the new jQuery UI file, and everything works fine now. My new asset file is:

//= require jquery
//= require jquery/jquery-ui
//= require jquery_ujs
// Loads all Bootstrap javascripts
//= require bootstrap
//= require rails.validations

//= require_tree .

jquery is a sub-folder in my javascripts folder.

Upvotes: 2

Andrei Zisu
Andrei Zisu

Reputation: 4383

I had the same problems, application.js looked like this:

//= require jquery
//= require jquery_ujs
//= require jquery-ui

In development mode, it seems /assets/application.js contained a version of jQuery bundled with ujs, and, when added to the page, it was like this:

<script src="jquery"></script>
<script src="jquery_ujs"></script>
<script src="jquery-ui"></script>
<script src="application.js"></script>

The last file was overriding the first three files. I put:

//= require_self
//= require jquery-ui

and it works fine.

The funny thing is, application.js only contains require lines, no jQuery or ujs.

Upvotes: 3

urandom
urandom

Reputation: 301

You might have precompiled your assets at an earlier point. Try to remove everything under public/assets.

Upvotes: 2

Related Questions