IE Primefaces 输入密钥提交解决方法

发布于 2024-10-31 14:38:58 字数 1647 浏览 0 评论 0原文

我遇到过 IE 不允许我按 Enter 键提交表单的问题。我找到了部分解决方案(http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter),但我的对话框窗口关闭了。我的验证已运行并显示错误消息。我如何保持对话框打开?

<p:dialog id="sgupdlg" header="#{bundle['signUp.HEADER']}" widgetVar="signUpDlg"
        modal="true" styleClass="dialog dialog1" draggable="false"
        resizable="false" showEffect="fade" hideEffect="fade" position="top">
        <h:form id="signUpFrm" binding="#{signUpDetail.signUpFrm}">
        <p:growl id="growl" showDetail="true" showSummary="false" life="3000" errorIcon="/images/Validation-Error.png" infoIcon="/images/Validation-Success.png"/> 

        <p:inputText value="#{signUpDetailBean.firstName}" name="nameInput" required="true" requiredMessage="First Name is Required"/>
        <p:inputText value="#{signUpDetailBean.lastName}" required="true" requiredMessage="Last Name is Required"/> 

        <p:commandButton styleClass="form-btn2"
                        value="#{bundle['signUp.button.LABEL']}" actionListener="#{signUpDetail.signUp}" onclick="trackingSignUpOverlaySave()" 
                        oncomplete="handleSignUpRequest(xhr, status, args)" update="growl"/>
        <p:commandButton type="reset" styleClass="close" />

        </h:form>
    </p:dialog>
    <script type="text/javascript">  


        $ = jQuery
        $(function(){
            $('input').keydown(function(e){
                if (e.keyCode == 13) {
                    $('#signUpFrm').submit();
                    return false;
                }
            });
        });


    </script>  

I've run into and issue with IE not allowing me to hit the enter key to submit a form. I found a partial solution (http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter) but my dialog window closes. My validations are run and the error messages are displayed. How would I keep my dialog open?

<p:dialog id="sgupdlg" header="#{bundle['signUp.HEADER']}" widgetVar="signUpDlg"
        modal="true" styleClass="dialog dialog1" draggable="false"
        resizable="false" showEffect="fade" hideEffect="fade" position="top">
        <h:form id="signUpFrm" binding="#{signUpDetail.signUpFrm}">
        <p:growl id="growl" showDetail="true" showSummary="false" life="3000" errorIcon="/images/Validation-Error.png" infoIcon="/images/Validation-Success.png"/> 

        <p:inputText value="#{signUpDetailBean.firstName}" name="nameInput" required="true" requiredMessage="First Name is Required"/>
        <p:inputText value="#{signUpDetailBean.lastName}" required="true" requiredMessage="Last Name is Required"/> 

        <p:commandButton styleClass="form-btn2"
                        value="#{bundle['signUp.button.LABEL']}" actionListener="#{signUpDetail.signUp}" onclick="trackingSignUpOverlaySave()" 
                        oncomplete="handleSignUpRequest(xhr, status, args)" update="growl"/>
        <p:commandButton type="reset" styleClass="close" />

        </h:form>
    </p:dialog>
    <script type="text/javascript">  


        $ = jQuery
        $(function(){
            $('input').keydown(function(e){
                if (e.keyCode == 13) {
                    $('#signUpFrm').submit();
                    return false;
                }
            });
        });


    </script>  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷…雨湿花 2024-11-07 14:38:58
function closeWhenValidationSuccesful(dialog, xhr, status, args) {
    if (!args.validationFailed) {
        dialog.hide();
    } 
}

<p:commandButton value="Save" action="doSomething" update=":formName:panelContainingValidatedElements"
    oncomplete="closeWhenValidationSuccesful(dialogWidgetVar, xhr, status, args)" />

我使用以下命令保持对话框打开并显示验证错误。您需要将输入移动到 panelGrid 中,以便更新属性可以将其作为目标。

function closeWhenValidationSuccesful(dialog, xhr, status, args) {
    if (!args.validationFailed) {
        dialog.hide();
    } 
}

<p:commandButton value="Save" action="doSomething" update=":formName:panelContainingValidatedElements"
    oncomplete="closeWhenValidationSuccesful(dialogWidgetVar, xhr, status, args)" />

I use the following to keep a dialog open and display validation errors. You will need to move your inputs into a panelGrid so that it can be target by the update attribute.

多彩岁月 2024-11-07 14:38:58

一个简单的标签就可以解决这个问题。

oncomplete="if (args.validationFailed){} else {Professor.show(),Student.hide();}"

您应该将此应用于 Professor 小部件变量

A simple tag would solve it.

oncomplete="if (args.validationFailed){} else {Professor.show(),Student.hide();}"

you suppose to apply this on Professor widget var

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文