jquery-rails upgrade breaking existing code which depends on older versions of jQuery Core (1.8.2)

68 views
Skip to first unread message

Brandon

unread,
Mar 18, 2014, 4:45:06 AM3/18/14
to rubyonra...@googlegroups.com
How do you manage different scripts that need different versions of jQuery to work properly?

I used to be able to use No Conflict even though it was kinda messy too. But at least I could get all the scripts working without one breaking the other due to different jQuery Core dependencies.


Walter Lee Davis

unread,
Mar 18, 2014, 9:14:32 AM3/18/14
to rubyonra...@googlegroups.com
Like this: http://youmightnotneedjquery.com/

Walter

On Mar 18, 2014, at 4:45 AM, Brandon wrote:

> How do you manage different scripts that need different versions of jQuery to work properly?
>
> I used to be able to use No Conflict even though it was kinda messy too. But at least I could get all the scripts working without one breaking the other due to different jQuery Core dependencies.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f5b222a7-afef-40dc-9df9-f85622e3d55b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Abdulsattar Mohammed

unread,
Mar 18, 2014, 9:43:55 AM3/18/14
to rubyonra...@googlegroups.com
You might want to use $.noConflict() as shown in this stackoverflow answer: http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page



For more options, visit https://groups.google.com/d/optout.



--
Regards,
Abdulsattar Mohammed

Brandon

unread,
Mar 18, 2014, 10:39:07 AM3/18/14
to rubyonra...@googlegroups.com
I see.. what about jQuery UI and jQuery Ujs which depends on those specific jQuery Core? How would I adapt those versions with noConflict?

Brandon

unread,
Mar 19, 2014, 6:21:57 AM3/19/14
to rubyonra...@googlegroups.com
So I tried noConflict but it didn't work.

    <script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var jq183 = $.noConflict(true);
    </script>
    <script src="/assets/jquery.inlineedit.js" type="text/javascript"></script>

Then inside jquery.inlineedit.js:

(function($) {

  // define inlineEdit method
  $.fn.inlineEdit = function(options) {
     ...
  }
})(jq183);

Not sure why it doesn't work! Can't do inline edit where it used to work!

Brandon

unread,
Mar 20, 2014, 5:30:05 AM3/20/14
to rubyonra...@googlegroups.com
Got this fixed.

Basically I put '$.fn.jquery' inside each scripts after NoConflict block to check the version and made sure the 1.8.2 version came through to them.

Brandon

unread,
Mar 21, 2014, 3:13:03 AM3/21/14
to rubyonra...@googlegroups.com
Thought I'd share how I got it all working in the Asset Pipeline.


//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-modalmanager
//= require bootstrap-modal
//= require jquery.easing
//= require jquery.cookie
//= require zeroclipboard
//= require jquery-1.9.0.min
//= require noconflict.jquery-1.9.0
//= require toggles
//= require jquery-1.10.1.min
//= require noconflict.jquery-1.10.1
//= require jquery.joyride-2.1
//= require jquery-1.7.2.min
//= require jquery-ui-1.8.7.custom.min
//= require noconflict.jquery-1.7.2
//= require jquery.inlineedit
//= require pubsub
//= require base
Reply all
Reply to author
Forward
0 new messages