atom feed16 messages in org.apache.tapestry.usersRe: integrating jQuery components
FromSent OnAttachments
Joachim Van der AuweraJun 17, 2009 12:47 am 
Angelo ChenJun 17, 2009 1:07 am 
Andy PahneJun 17, 2009 2:57 am 
Onno ScheffersJun 17, 2009 3:07 am 
Onno ScheffersJun 17, 2009 3:33 am 
Angelo ChenJun 17, 2009 3:40 am 
Joachim Van der AuweraJun 17, 2009 4:10 am 
Joachim Van der AuweraJun 17, 2009 4:16 am 
Andy PahneJun 17, 2009 5:18 am 
Onno ScheffersJun 17, 2009 5:25 am 
Onno ScheffersJun 17, 2009 5:42 am 
Onno ScheffersJun 17, 2009 5:46 am 
Michael GentryJun 17, 2009 5:56 am 
Massimo LusettiJun 17, 2009 6:50 am 
Andy PahneJun 17, 2009 6:59 am 
Massimo LusettiJun 17, 2009 7:03 am 
Subject:Re: integrating jQuery components
From:Onno Scheffers (on@piraya.nl)
Date:Jun 17, 2009 3:33:53 am
List:org.apache.tapestry.users

I am curious how you managed to include jQuery with @IncludeJavascriptlibrary. I only managed that with a patched version of jQuery, adding jQuery.noConflict() at the end of the jQuery javascript file. Otherwise there were Javascript bugs... (using current stable 5.1 Tapestry release)

This issue only really applies if you are using both Prototype and jQuery in your application. I think most people won't want to do that once jQuery is officially supported.

If both Prototype and jQuery are used in your application, then ordering of the included libraries is imporant. jQuery assigns itself to the $-variable but stores whatever was in that variable before. Using jQuery.noConflict(), whatever was in the $-variable will be put back there.

Internally and in 3rd party jQuery plugins, the $-variable should never be used, but the jQuery namespace is used instead. The short $-notation is only there for end-users and can easily be reassigned to something else.

Sadly Prototype and its plugins are not written to work against their own namespace as far as I can tell. Therefore they rely on the $-var being assigned to Prototype.

So as soon as the jQuery library is included, the $-variable is assigned to jQuery. Then some Prototype-libraries are included that depend on the $-variable being assigned to Prototype. Since it is assigned to jQuery, they will cause Javascript-errors.

Only after all libraries are included, you get a chance to call jQuery.noConflict(), which is too late since the JavaScript errors have already occured.

I also added the jQuery.noConflict()-call to the jquery.js file in my applications so far.

But this is an area that needs some work when adding jQuery support. By default, you don't want to force the noConflict-mode onto users, since they like programming against the $-notation. But if both Prototype and jQuery are used, or even forced upon you by 3rd party components, then we should include the jQuery noConflict() call right after jQuery has been included.

regards,

Onno