>
> 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

Reply via email to