使用A4J,如何重新呈现javascript函数,并在重新呈现后调用它? [英] using A4J, how do I rerender a javascript function, and call it after rerendering?
问题描述
例如,我尝试过
<a4j:region id="scriptSuggested" >
<f:verbatim>
<script>
reallyUpdateIt = function () {
// javascript code that changes after aj4 ajax call is triggered
}
</script>
</f:verbatim>
<a4j:jsFunction reRender="scriptSuggested" ignoreDupResponses="true" ajaxSingle="true" name="updateSuggestionValues" action="#{bean.action}" oncomplete="reallyUpdateIt();">
<a4j:actionparam name="userInput" assignTo="#{bean.input}" />
</a4j:jsFunction>
</a4j:region>
我希望调用javascript函数
I would expect that calling the javascript function
updateSuggestionValues('val');
将要采取行动
#{bean.action}
,然后它将重新渲染区域scriptSuggested
,最后将调用reallyUpdateIt()
,
and after that it would rerender the region scriptSuggested
and finally would call reallyUpdateIt()
,
除了更新reallyUpdateIt()
的代码部分之外,所有其他方法均有效,我使用firebug检查了ajax响应,它附带了预期的新javascript代码,但是当我调用reallyUpdateIt()
时,将触发旧代码.
all works except the part of updating the code of reallyUpdateIt()
, I checked the ajax response using firebug, and it comes with the expected new javascript code, but when I call reallyUpdateIt()
, the old code is triggered.
我正在使用JSF 1.2,richfaces 3.3.3,
I am using JSF 1.2, richfaces 3.3.3,
推荐答案
事实证明,使用<a4j:region id="scriptSuggested" >
不会生成A4J可以重新呈现的html节,我不得不使用<a4j:outputPanel>
,所以现在它更新了功能,我的代码现在看起来像:
it turns out using <a4j:region id="scriptSuggested" >
doesn't generate an html section that A4J can rerender, I had to use <a4j:outputPanel>
, so now it updates the function, my code now looks like :
<a4j:region >
<a4j:outputPanel id="scriptSuggested">
<f:verbatim>
<script>
reallyUpdateIt = function () {
// javascript code that changes after aj4 ajax call is triggered
}
</script>
</f:verbatim>
<a4j:jsFunction reRender="scriptSuggested" ignoreDupResponses="true" ajaxSingle="true" name="updateSuggestionValues" action="#{bean.action}" oncomplete="reallyUpdateIt();">
<a4j:actionparam name="userInput" assignTo="#{bean.input}" />
</a4j:jsFunction>
</a4j:outputPanel>
</a4j:region>
这篇关于使用A4J,如何重新呈现javascript函数,并在重新呈现后调用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!