引导按钮用于将一些数据提交到SQL Server DB。我希望在用户单击一次时禁用该按钮。但奇怪的是, 我必须“快速”两次单击该按钮才能将其禁用。但无论你如何点击它,onCommand c#函数运行良好。 所以这是代码
<div style="margin-top:5px; margin-bottom:10px; text-align:center; ">
<asp:UpdatePanel ID="Ajax_SubmitReportRoom" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="SubmitReportRoom" type="button" CssClass="btn btn-info SubmitReport" OnClientClick="toggleVisibility();" runat="server" Text="Submit" OnCommand="SubmitReport_Command" CommandName="ReportRoom" CausesValidation="true" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SubmitReportRoom" />
</Triggers>
</asp:UpdatePanel>
</div>
<script type="text/javascript">
function toggleVisibility(){
$('.SubmitReport').addClass('disabled');
//$('.SubmitReport').attr("data-toggle", "modal"); // for some reason this is needed to disable the button but this causes OnCommand function to stop running
}
答案 0 :(得分:1)
试试这个
function toggleVisibility(){
$('.SubmitReport').addClass('disabled').attr("data-toggle", "modal");
}
答案 1 :(得分:0)
尝试.attr(&#39;禁用&#39;,&#39;禁用&#39;)而不是addClass
答案 2 :(得分:0)
试试这个:
itertools.chain.from_iterable
答案 3 :(得分:0)
在这种情况下禁用按钮的简单代码调用click事件上的toggleVisibility函数并在代码下面进行处理。
function toggleVisibility(){
$('button').prop("disabled", true);
}