cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@apache.org>
Subject Re: RFC: Ajax Roadmap
Date Fri, 09 Dec 2005 18:04:26 GMT
Hi Ralph

On 9 Dec 2005, at 15:06, Ralph Goers wrote:

> Jeremy Quinn wrote:
>
>> The first thing I have done is to use the dojo.require mechanism  
>> to  dynamically load all JS in the browser, so for instance, if  
>> your form  does not use htmlarea, the javascripts are not loaded :)
>
> If there are multiple forms on a page (i.e. in the portal) will  
> multiple copies be loaded?


I don't know :)

Is there anything in the portal samples I can try this on?

With my changes, forms processed through the built-in cforms xslt now  
only load 2 files via script tags :

	<script type="text/javascript" src="{$resources-uri}/ajax/dojo/ 
dojo.js" > </script>
	<script type="text/javascript" src="{$resources-uri}/ajax/js/ 
cocoon.js" > </script>

The first one gets dojo bootstrapped, the second plugs in Cocoon's  
namespace to the script loader, so we keep our code separate.

Then the other libs are 'required' as appropriate. eg. these are  
always used (these samples are using the 'old' names) :

	<script type="text/javascript">
     	    dojo.require("cocoon.forms.forms-lib");
     	    dojo.require("cocoon.forms.cforms");
	</script>
or
	<xsl:template match="fi:form-template|fi:form-generated">
		. . .
		<xsl:if test="@ajax = 'true'">
			<script script="text/javascript">
			    dojo.require("cocoon.ajax.cocoon-ajax");
			    cocoon.forms.ajax = true;
			</script>
		</xsl:if>
		. . .
	</xsl:template>

If the same dojo.require is called several times, only the first one  
results in a file actually loading.

HTH

regards Jeremy
Mime
View raw message