阿贾克斯不能与一个jQuery幻灯片放映的权利JSF [英] Ajax not working right in JSF with a jquery slide

查看:113
本文介绍了阿贾克斯不能与一个jQuery幻灯片放映的权利JSF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的应用程序写在 JSF 2.0 Facelets的,然后它有一个应该显示在一个地区的一些内容如下code其中的 jQuery的滑块控件这意味着你preSS一个按钮,这又显示区和preSS将其隐藏

I have this application written in JSF 2.0 facelets and it has the following code that supposed to display some content in an area which a jQuery slide controls, meaning that you press a button that displays that area and press it again to hide it

<f:ajax render="messageID">
      <h:form id="myform" styleClass="form1" >
          <h:message id="messageID" for="signinemail" class="messageforlogin"/>
          <h:panelGrid styleClass="loginpanel" columns="2" cellspacing="4">

          <h:outputText value="Email: "/>
          <h:inputText class="textboxes"  size="20" id="signinemail" 
                      value="#{signinBean.email}" 
                      validatorMessage="Invalid Email, Try Again">
              <f:validateRegex pattern="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"/>

          </h:inputText>

正如你可以看到有一个错误信息如果邮件不正确输入应该被显示,并作为我这个领域之前说的是控制与jquery.slidetoggle功能按钮,使它的滑动输入的东西在,

As you can see there is an error message that should be displayed if the email is not typed correctly, and as i said before this area is controlled with a jquery.slidetoggle function and button that makes it a slide to input the stuff in,

的事情是,当使用presses提交按钮(图中未显示)的滑动冻结并显示任何错误消息,当我删除,显示消息的Ajax的,但幻灯片消失,你必须preSS切换按钮再次看到错误消息的幻灯片,我在同一个网页,但与出幻灯片做到了这一点,它wokrs非常精细。

The thing is when the use presses the submit button(not shown here) the slide freezes and no error message is displayed,When i remove the "ajax" the message is displayed but the slide disappears and you have to press the toggle button again to see the slide with the error messages, i have done this in the same page but with out a slide and it wokrs very fine.

有没有去显示它???幻灯片和错误信息

Is there away to display the slide and the error messages on it ???

推荐答案

jQuery的脚本负责设置幻灯片应重新执行JSF AJAX请求完成时,仅仅是因为Ajax响应更改/替换元素的的HTML DOM树与来自这反过来当然不包含那些jQuery的初始化事件处理程序再在服务器检索到的新的元素。 jQuery的脚本不是自动执行每次Ajax请求完成时,但只有当你刷新页面。

The jQuery script which is responsible for setting the slides should be re-executed when the JSF ajax request completes, simply because the ajax response changes/replaces elements in the HTML DOM tree with new elements retrieved from the server which in turn of course do not contain those jQuery-initialized event handlers anymore. The jQuery script is not auto-executed everytime when the ajax request completes, but only whenever you refresh the page.

您只需要在JSF AJAX事件处理程序的回调中重新调用你的jQuery函数如下:

You just need to re-invoke your jQuery function in the JSF ajax event callback handler as follows:

jsf.ajax.addOnEvent(function(data) {
    if (data.status == "success") {
        yourjQueryFunctionWhichAddsTheSlideEvents();
    }
});

另一种方法是使用OmniFaces &LT;○:onloadScript&GT;

<o:onloadScript>yourjQueryFunctionWhichAddsTheSlideEvents();</o:onloadScript>

这种方式,你也并不需要一个 $(文件)。就绪()了。

这篇关于阿贾克斯不能与一个jQuery幻灯片放映的权利JSF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆