jQuery and old Prototype on the same page
by Tim Dupree at 9:54 am on July 21st, 2009 | 1 comment
This morning I had to implement an interactive map that allows one to locate local dealers of GPS equipment. The site I needed to do this on is running an extremely old version of prototype.js (version 1.5, circa 2007) and moodom.js (the precursor to MooTools). I didn’t want to use these outdated libraries to create the little interactive app. I would normally use MooTools, but I needed a library I could namespace so that I wouldn’t step on Prototype’s shoes. I grabbed the latest build of jQuery, namespaced it using the jQuery.noConflict(); technique, wrote my code, and included it right before the /body tag of document.
Everything worked fine in Firefox and IE. When I went to test it in Chrome and Safari non of the functionality worked and I received an error such as “TypeError: Result of expression ‘jQuery(document).ready’ [undefined] is not a function”. I tried some workarounds and got rid of the above error but was stuck with “Error: NOT_SUPPORTED_ERR: DOM Exception 9″ referring to line 1081 of prototype.js.
Eventually, in searching the net, I stumbled across the solution. If you need to use jQuery with an old version of prototype/scriptaculous/moodom, make sure you load your namespaced jQuery library, and any jQuery code you write, BEFORE the other legacy js frameworks. Works like a charm now.
Comments
thanks a lot. this really helped.
1. montyburns, July 24th, 2009 at 8:24 pm
Leave a Comment