Ticket #12207 (closed bug: invalid)
jQuery.noConflict deletes jQuery replacement variable...
|Reported by:||WriterDan||Owned by:|
There's an example on the jQuery.noConflict page as follows:
Example: Creates a different alias instead of jQuery to use in the rest of the script:
var j = jQuery.noConflict(); Do something with jQuery j("div p").hide(); Do something with another library's $() $("content").style.display = 'none';
This method is genius, and I use it quite often. I recently had a problem with it though, because of some code that someone else wrote.
Instead of including:
var j = jQuery.noConflict();
like your example, they used:
var jQuery = jQuery.noConflict();
This seems to work fine in FF, Chrome, Safari, and IE9; however, in IE8 and IE7, it looks like the noConflict directive deletes the new jQuery variable that is being defined by the above statement. That definition was placed outside of any document.ready declarations on this site I was working on, so it looked like jQuery just wasn't loading for IE8 or IE7, which was annoying. At the conclusion of my three-day debug session, I just had to laugh.
The site was using jQuery 1.5, but in amongst my debugging I verified that 1.7.2 behaved the same way.
I don't know if you'd qualify this as a "bug" necessarily or perhaps just poor programming practices on someone else's part, but I had it nailed into my head during graduate school that when building software you shouldn't build it so that it works, you should build it so that it doesn't break. :) Thus, I'm reporting it.