jQuery.noConflict for logged in users problem

edited December 2012 in News & Announcements
Hello everyone,

is there some js guru who can help identify a possible issue with multiple jQuery instances please?

The problem (short version) is: (on a certain frontend controller-rendered view)

- load jquery-1.8.3.min.js
- load jquery.chosen plugin (http://harvesthq.github.com/chosen/)
- init chosen

but when I'm logged in as admin (and the fuel edit bar is loaded together with jquery 1.5) the chosen plugin stops working, with an "method 'chosen' does not exist" error (which usually comes from jquery conflicts).

I've tried isolating both my script and /fuel/modules/fuel/js/edit_mode.js with a noConflict wrapper like so

(my script)

var jq18 = jQuery.noConflict;
(function($) {


var jq15 = jQuery.noConflict;
(function($) {

(also i've made sure this works by alerting the $().jquery version and it does indeed work)

but the problem still persits.
If i log out the plugin works again so I'm assuming the cause MUST be with the older jquery version conflict spawned by the fuel bar...

any clues?


  • edited 10:52AM
    If you remove the jQuery.noConflict(); from the top of the fuel/modules/fuel/assets/js/fuel/edit_mode.js file does it work? The 1.0 beta has that removed due to probably some similar issues.
  • edited 10:52AM
    nope :(
  • edited 10:52AM
    All I can add (perhaps unhelpfully!) is that I can't replicate in 1.0... works fine:

  • edited 10:52AM
    Hmm... I would start by looking at if there is something in the that edit_mode.js file or if there is a js file being included that's causing the problem in the fuel/modules/fuel/views/_blocks/inline_edit_bar.php file.
  • edited 10:52AM

    so it seems that the cause is indeed the older jquery version being included by inline_edit_bar.php. If i remove 'jquery/jquery' from the js() call chosen works again (and so does the inline editing bar, since jquery is being also loaded by my view (albeit v 1.8 )

    Having said that, I've resorted to wrapping the whole jquery 1.5 within a

    if (typeof jQuery == 'undefined') {
    [jquery 1.5 source here ...]

    But it's (w)hack-y! I wish there was a cleaner solution... ! cheers
  • jQuery.noConflict() method allows you to use multiple frameworks , while using jQuery. The noConflict() method releases the hold on the $ shortcut identifier, so that other scripts can use it. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. In case of multiple versions of jQuery are loaded (which is not recommended), calling $.noConflict(true) from the second version will return the globally scoped jQuery variables to those of the first version.

Sign In or Register to comment.