How to stub jquery in my asset pipeline?

I am using Rails 3.2 and the jquery-ui-rails plugin to add datepicker to the JS manifest file.

This is my manifest file:

//= require jquery_ujs //= require jquery.ui.datepicker //= require_tree . 

I get my jQuery library separate from the Google CDN.

However, by adding jquery.ui to the manifest file, it automatically includes its jQuery dependency, so now I end up with two jQueries in my final HTML document.

I don't need this additional jQuery file - I only need one from the Google CDN. Using asterisks, I can use the stub directive to selectively "exclude" the jQuery file.

So this is what I did - and it didn't work - i.e. jQuery is still being added to my last js file ...

 //= stub jquery //= require jquery_ujs //= require jquery.ui.datepicker //= require_tree . 

I tried several combinations:

 //= stub jquery.js //= stub "jquery" //= stub "jquery.js" //= stub "/jquery.js" 

etc.

But none of these works. I could not find an example wherever he worked. By the way, I also tried

 //= stub jquery_ujs 

What did not close the jquery_ujs library ...

+4
source share
2 answers

I think the reason it doesn't work is that Rails 3.2.x only uses sprockets v2.1. However, notes are only available in chains> = 2.2. You can try manually updating the stars (forking actionpack).

+3
source

You can always just take the jquery_ujs file, drop it into vendor/javascripts , remove the jquery-rails from your Gemfile, and then include in your manifest that js was sent to.

0
source

All Articles