mennake / thematic

Automatically exported from code.google.com/p/thematic
0 stars 0 forks source link

jQuery Conflicts w/ noConflict #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install thematic
2. Install plugin or code snippet that uses another version of jQuery, 
somewhere lower down the page
3. Get conflicts

What is the expected output? What do you see instead?
Shouldn't break due to jQuery noConflict being set, breaks anyway.

What version of the product are you using? On what operating system?
Latest

Please provide any additional information below.

I've noticed that jQuery is linked by default, further from where noConflict is 
set. Some other plugins load other versions of jQuery and also set noConflict, 
but in between where jQuery is loaded and the script is called. This ends up 
breaking jQuery and various scripts on the page.

In order to truly make jQuery noConflict work, you could set it to something 
like 
var my_jq = jQuery.noConflict();
Directly after jQuery is loaded.

And then wrap the scripts in 
;(function($) { 
...Code here
})( my_jq );

By just setting noConflct, it protects against conflicts with other javascript 
frameworks, but not other versions of jQuery, especially when they are spread 
out across the html template.

Original issue reported on code.google.com by zenji...@gmail.com on 15 Apr 2011 at 8:43

GoogleCodeExporter commented 9 years ago
Hi,

please, do not use jQuery.noConflict() at all. 
This may break any other plugin on your site.

It's sufficiently safe to just use jQuery like this (note that I don't use "$" 
at all):

jQuery(document).ready(function() {
  someFunction();
});

(function(jQuery) {
  someFunction = function() {
    jQuery("someselector").someMethod();
  }
})(jQuery);

Cheers,
Arne

Original comment by arne.fra...@gmail.com on 3 Jun 2011 at 9:50

GoogleCodeExporter commented 9 years ago
noConflict is removed

Original comment by chris.gossmann@googlemail.com on 1 Sep 2011 at 2:41