IE8: fix for coexistence problem prototype.js (1.6.1) with jQuery (1.3.2)

423 views
Skip to first unread message

Hubert + Associates GmbH & CoKG

unread,
Nov 6, 2009, 2:37:25 AM11/6/09
to Prototype & script.aculo.us, subs...@ricwave.com
Hi,

I had a "pure" prototype.js site until I was obliged to use jQuery
indirectly by a library provider (Telerik). Telerik does a good job,
but even they are no match for IE8, which is the only browser (we test
6) that had a problem with this. Our first reaction was to tell IE8 to
jump in the Pacific, but then we got real again, and devised the
following (hack) fix. Once the following is done, they work fine
together (there are posts on the web stating that it is impossible to
even use prototype.js on IE8 - humbug!).

So here it is, perhaps there is a way to publish a real fix using this
information, since I believe that it is an IE problem, not jQuery.
Also, any tips on better/other fixes or logical explanations to this
would be appreciated.

On line 2267 of jQuery 1.3.2, browser tests are done, once: a call to
div.getElementsByClassName("e")
This ends up in protype.js instanceMethods.getElementsByClassName
(line 4811).

In IE8 (only) the "$" operator is still the jQuery $ operator, not the
protytype $, even though the jQuery.noConflict(); is the first thing
called (by us and by telerik), globally, after loading jQuery and
before loading prototype.js (could be the other way around if
prototype had a .noConflict() feature). IE8 apparently (definitely)
has a different js initialization sequence than other browsers which
causes this problem, and IE8 brings an error of "object not defined"
at prototype.js line 4821 (where the $ operator is required). So, our
hack -- for lack of a better fix -- is to simply check the broswer
type and the className and return an empty array. So, at line
prototype.js 4817, we insert:

if (Prototype.Browser.IE) { if (className == 'e') return []; }

Then both jQuery and prototype.js coexist, whereby jQuery has been
assigned another $ operator via var $j = $.noConflict();

Make sense? Comments or tips? It would be nice to not have to patch
prototype.js for this... Maybe someone could fix IE8? :-)

Thanks,
R

Alex McAuley

unread,
Nov 6, 2009, 12:31:43 PM11/6/09
to prototype-s...@googlegroups.com
I have commented on this many a time...

In order for them to co-exist properly you need to assign Jquery to a
variable

var $jq=jQuery.noConflict();

this will transpose to (most) if not all plugins --- certainly all the UI
stuff works with this method and no source changes


Alex Mcauley
http://www.thevacancymarket.com
Reply all
Reply to author
Forward
0 new messages