$(文件)。就绪()F后不运行:AJAX渲染 [英] $(document).ready() doesn't run after f:ajax rendering
问题描述
我有一个运行在每个 $(文件)。就绪()
事件部分的jQuery
code 。
我也有一些< F:。AJAX>
标记做重新渲染页面的某些部分。
I have some jQuery
code that runs on every $(document).ready()
event.
I also have some <f:ajax>
tags that do re-rendering of some parts of the page.
我注意到,当我重新呈现一个组成部分,在 $(文件)。就绪()
不会被调用。
I noticed that when I rerender a component, the $(document).ready()
doesn't get called.
有没有办法运行后,每个JavaScript code &LT; F:AJAX&GT;
重新描绘?
(我可以在技术上使用的OnEvent
标记,但是这是不利的解决方案给我,因为我必须调用每个函数&LT; F:AJAX&GT;
)
Is there a way to run javascript code after every <f:ajax>
rerendering?
(I can technically use the onevent
tag but that's the unfavourable solution to me since I will have to call the function on every <f:ajax>
)
为了方便说明,这是jQuery的code:的
$(document).ready(function() { ...CODE... }
而JSF code:的
<f:ajax event="click" render=":someComponentID"/>
谢谢!
更新:此问题可能是这其中的一个副本。我找了进去。
UPDATE This question might be a duplicate of this one. I'm looking into it.
UPDATE2 这是一个容易解决的使用JSF的Javascript事件绑定:
UPDATE2 This is easily solvable using the JSF Javascript event binding:
jsf.ajax.addOnEvent(function(data){
if (data.status === 'success') {
// Do stuff here
}
}
在JSF 2参考阅读更多有关它
Read more about it under the JSF 2 reference
推荐答案
在 $(文件)。就绪()
事件触发一次,当DOM已完全加载初始加载。
The $(document).ready()
event fires once, when the DOM has fully loaded from the initial load.
这是AJAX事件可能会改变DOM,但它不刷新页面,所以 $(文件)。就绪()
会不会再次触发。
An ajax event may change the DOM, but it doesn't reload the page, so the $(document).ready()
won't fire again.
我注意到的方式谷歌在Gmail中解决了这个问题,通过使用的高频定时器。
I noticed the way Google solved this problem in Gmail is by using a high frequency timer.
这篇关于$(文件)。就绪()F后不运行:AJAX渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!