Hi,
to execute events when the page has been loaded, don't use <body
onload="...">.
first it won't work in the current design unless we set a list of
properties for the page in the theme definition file, it would be
possible for instance to do:
<widget element="page">
<onload-script>setFocus()</onload-script>
<onload-script>doSomething()</onload-script>
</widget>
but that's really ugly because we don't know in advance which widgets
will be added to the page by the user. In the case of CPS3 there was a
setFocus() function called by default that expected a search form.
so a better pattern is to declare the javascript events in a separate
file and register them programmatically instead. In this way any widget
can declare a dependency on a javascript init file with for instance:
<view name="cool menu widget">
<element-type>fragment</element-type>
<format-type>widget</format-type>
<model-type>menu item</model-type>
<class>org.nuxeo.theme.jsf.views.JSFView</class>
<template>.../widgets/cool-menu.xml</template>
<resource>cool-menu.js</resource>
</view>
and inside 'cool-menu.js' you place the code the is supposed to be
called when the page is loaded.
in this way the javascript code is associated to the WIDGET and not to
the PAGE or the THEME.
I know that jquery has a method called $(document).ready() { ... } which
allows to register several events once the page has been loaded.
see http://www.ubercart.org/uberlearn/starting_jquery
Yahoo's YUI also has something similar
see http://developer.yahoo.com/yui/event/#onavailable
I can extract the function and place it in nxthemes.js
/JM
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm