How to dynamically include all scripts in a page using body onload event
I am trying to include a page (a.xhtml) using <ui:include>
inside <rich:dataT开发者_运维技巧able/>
. The included page contains a script to load a image. Based on the number
of iterations script will be included with different function names. I want
to call all the javascript function in a page on body onload event. How to do this?
My code will look like this
a.xhtml
<f:subview>
<canvas id="#{canvasId}"/>
<script>
function #{fnName}() {
...
}
</script>
</f:sunView>
b.xhtml
<rich:panel>
<html>
<body>
<tich:dataTable var="item" value=#{items}" rowKeyVar="num">
<rich:column>
<ui:include src="a.xhtml"
<ui:param name="canvasId" value="img_#{num}"/>
<ui:param name="fnName" value="fn_#{num}"/>
</ui:include>
</rich:column>
<rich:dataTable>
</body>
</html>
</rich:panel>
jQuery.getScript -> try using this to fetch the javascript when the load (onLoad) of your new page is done. You can write this logic once for the first occurrence, so that the script is already loaded for subsequent usage.
精彩评论