我需要实现这一目标。当用户单击按钮时,我们需要阻止用户在操作完成之前再次单击该按钮。它在Firefox中工作。但不是在IE和Chrome中。我需要在IE和Chrome中设置任何设置吗?我正在使用primefaces 3.5。
我也试过.attr。 Firefox正在运行,但IE和Chrome无法运行。
XHTML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:hx="http://www.ibm.com/jsf/html_extended">
<h:head>
<title>Enterprise</title>
<meta http-equiv="keywords" content="enter,your,keywords,here" />
<meta http-equiv="description"
content="A short description of this page." />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet"
href="#{request.contextPath}/theme/primefaces-aristo/themeMain.css" />
<link rel="SHORTCUT ICON" href="../../theme/csl.ico" id="ma1001" />
<script src="../../scripting.js"></script>
<script type="text/javascript">
jQuery('form1').submit(function() {
jQuery('input[type=submit]', this).prop('disabled', true);
});
</script>
<f:view locale="#{pc_Ma1001.userLocale}" />
<f:loadBundle basename="messages.MessageResources" var="msg" />
</h:head>
<f:metadata>
<f:event listener="#{pc_Ma1001.onPageLoadBegin}" type="preRenderView"></f:event>
</f:metadata>
<h:body>
<h:form id="form1" enctype="multipart/form-data" prependId="false">
<ui:include src="../../theme/menubar.xhtml" />
<td><p:commandButton type="submit" value="Create"
styleClass="commandButton" id="maintenance_command_add"
action="#{pc_Ma1001.doMa1001_command_addAction}" ajax="false"></p:commandButton>
</td>
</h:form>
</h:body>
</html>
答案 0 :(得分:0)
尝试将您的脚本包装在DOM准备好中:
jQuery(document).ready(function(){
jQuery('#form1').submit(function() {
jQuery('input[type=submit]', this).prop('disabled', true);
});
})
答案 1 :(得分:-1)
试试这个:
jQuery('form1').submit(function(evt) {
jQuery('input[type=submit]', $(evt.target)).prop('disabled', true);
});