Forum OpenACS Q&A: Ajaxhelper, YUI and xowiki

Collapse
Posted by Richard Hamilton on
I have a little experience with coding using the YUI3 library using the dynamic loading capability and the terse declarative syntax, but no experience of using YUI2 and OpenACS Ajaxhelper.

I am trying to understand the xowiki carousel includelet so that I can modify it to work with the new YUI3 carousel.

From what I can see, AjaxHelper takes care of adding script tags to the page header for any Javascript modules that the page requires, and also provides a convenient way to add javascript library functions to dynamically generated pages.

YUI3 provides it own dynamic loader which loads only those modules that are required. I am not clear whether this means that YUI3 components need not be involved with Ajaxhelper, or whether I should start by adding YUI3 support to Ajaxhelper?

I can see that when adding YUI3 functions to an xowiki page I need only source the YUI3 dynamic loader and activate those modules used in the page, however when writing an includelet I guess the YUI3 dynamic loader should itself be loaded through Ajaxhelper as with YUI2.

Hopefully this will become clearer to me with time but for now I am finding the code quite confusing.

I would appreciate some guidance on this.

Regards
Richard

Collapse
Posted by Dave Bauer on
Hi,

I recommend avoiding ajaxhelper and using template::head to load whatever javascript you need.

Collapse
Posted by Richard Hamilton on
Thanks Dave, I will.

Regards
Richard

Collapse
Posted by Gustaf Neumann on
if you build on the xowiki-includelet infrastructure, i would recommend to use the same mechanism that the other 50+ includelet classes in xowiki use, namely require_YUI_CSS and require_YUI_JS. These functions allow you to use either locally installed versions (per default from the ajaxhelper package) for internet-free execution, or to use versions from the Yahoo content distribution network (yui.yahooapis.com). This is controlled via the ajaxhelper switch (it does not use the package - such as the ajaxhelper loader etc - just the files).

The require_YUI* methods provide an xowiki-specific configuration for all YUI needs in xowiki and friends. These functions control as well the YUI version numbers. The preconfigured version is YUI 2.7.0. In general, i would not recommend to mix YUI versions. Not all newer YUI versions are fully upward compatible, i had to step back e.g. from 2.8.* to 2.7.0 due to changes in drag and drop. If you use multiple YUI components from different YUI versions on a single page, you are probably asking for troubles.

Collapse
Posted by Richard Hamilton on
Right! Ok, thank you.

According to the YUI3 docs, YUI3 is completely encapsulated (they say sandboxed) so that it can co-exist safely with other instances of YUI3 and various YUI2 versions. However, I am in no hurry to create additional problems for myself! 😊

I think I will thrash this through using YUI2 and worry about migrating to YUI3 later.

R.