gpt4 book ai didi

javascript - 停止 Bootstrap Accordion 面板在表单提交时崩溃

转载 作者:行者123 更新时间:2023-11-30 17:05:52 24 4
gpt4 key购买 nike

我在 Bootstrap 3 可折叠面板中有一个表单。

表单是一个带有 EDIT 和 DELETE 按钮的 asp.net DetailsView 控件。

当我点击“编辑”时,面板会折叠,我需要再次点击它才能重新打开并完成编辑。

EDIT 按钮点击事件导致面板关闭。

为什么?我该如何防止这种情况发生?

这是标记(注意: Accordion 位于 UpdatePanel 内):

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">Associated Person Details
</a>
</h4>

</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
<asp:DynamicValidator runat="server" ID="DynamicValidator5" ControlToValidate="dvPartnerDetails" Display="None" EnableClientScript="true" />
<h4>Partner details:</h4>

<asp:DetailsView ID="dvPartnerDetails" runat="server" CssClass="detailstable" FieldHeaderStyle-CssClass="bold" AutoGenerateRows="false" DefaultMode="ReadOnly" EnableModelValidation="true" OnDataBound="dvPartnerDetails_DataBound" DataSourceID="dsPartnerDetails" DataKeyNames="PersonID">
<Fields>
<asp:DynamicField DataField="PartnerTitle" />
<asp:DynamicField DataField="PartnerForenames" />
<asp:DynamicField DataField="PartnerInitials" />
<asp:DynamicField DataField="PartnerSurname" />
<asp:DynamicField DataField="PartnerAddressee" />
<asp:DynamicField DataField="PartnerSalutation" />
</Fields>
<FieldHeaderStyle CssClass="bold" />
<FooterTemplate>
<div class="bottomhyperlink">
<asp:LinkButton ID="EditHyperLink" CausesValidation="false" CssClass="btn btn-default" runat="server" CommandName="Edit">Edit</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server" CssClass="btn btn-default" CausesValidation="false" CommandName="Delete" OnClientClick='return confirm("Are you sure you want to delete this record?");' Text="Delete" />
</div>
</FooterTemplate>
</asp:DetailsView>
</div>
</div>
</div>

最佳答案

问题是updatepanel总是带原代码,需要重新打开accordion。

<script type='text/javascript'>
$(document).ready(function() {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
});

function endRequestHandler(sender, args)
{
$('#collapseTwo').collapse.in()
}
</script>

关于javascript - 停止 Bootstrap Accordion 面板在表单提交时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28043009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com