我的页面上有以下按钮
<asp:Button ID="btnSignoff" runat="server" Text="Sign Off & Send" CssClass="btn btn-primary" OnClientClick="openSignOffModal(); return false;"/>
第一次点击按钮工作正常(显示模式弹出窗口)。当我再次按下按钮关闭弹出窗口后,现在它被禁用了。
这是默认行为吗?知道为什么它的表现如此吗?我该如何解决?
function openSignOffModal() {
//check if atleast one RCTI is selected
if (ValidateCheckBox())
$('#SignOffRCTIModal').modal();
else
$('#NoRCTISelectedModal').modal();
}
标记
<div class="modal hide" id="SignOffRCTIModal" style="width: 500px">
<div class="modal-header">
<h3>Sign Off RCTI</h3>
</div>
<div class="modal-body form-horizontal">
<asp:Panel ID="pnlSignOffRCTI" runat="server">
<p>
Are you sure you want to Signoff the selected RCTI(s)?
</p>
</asp:Panel>
</div>
<div class="modal-footer">
<asp:Button ID="btnConfirmSignOff" runat="server" CssClass="btn" Text="Sign Off and Send" CausesValidation="false" />
<button class="btn btn-primary" data-dismiss="modal" data-focus="true" id="btnCancel">Cancel</button>
</div>
</div>
<div class="modal hide" id="NoRCTISelectedModal" style="width: 500px">
<div class="modal-header">
<h3>No RCTI Selected</h3>
</div>
<div class="modal-body form-horizontal">
<asp:Panel ID="Panel2" runat="server">
<p>
Please select an RCTI first in order to proceed.
</p>
</asp:Panel>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" data-focus="true">OK</button>
</div>
</div>
P.S。我的页面上有ajax控件但是点击这个按钮没有任何内容会更新,所以我没有对它进行调整。
答案 0 :(得分:0)
Yayy!有用!所以在.master我已经定义了这样的属性
$("input[type='submit']").click(function (e) {
if (e.target && Page_IsValid) {
var SkipDoubleClickCheck =
$(this).attr('SkipDoubleClickCheck');
if (SkipDoubleClickCheck != 'undefined' && SkipDoubleClickCheck == "true") { //Skip if element has a specific attribute
return;
}
var attr = $(this).attr('submitting');
if (typeof attr !== 'undefined' && attr !== false) { // If button has submitting attribute, then do not submit it again.
$(this).prop('disabled', true);
$(this).removeAttr("submitting");
e.preventDefault();
}
else {
$(this).attr("submitting", "true"); // Adding "submitting" attribute to prevent multiple submissions.
}
}
});
实现需要在按钮中设置的属性SkipDoubleClickCheck =&#34; true&#34;
<asp:Button ID="btnSignoff" runat="server" text="Sign Off & Send" SkipDoubleClickCheck="true" CssClass="btn btn-primary" OnClientClick="openSignOffModal(); return false;"/></td>