C# can';不要让jqueryui手风琴在回发时保持活动索引
我环顾四周,找到了许多解决方案,但出于某种原因,这对我来说根本不起作用 .NET 4,c# 我有一架有三节的手风琴。在我的c#代码隐藏加载部分中,我有C# can';不要让jqueryui手风琴在回发时保持活动索引,c#,asp.net,jquery-ui,postback,accordion,C#,Asp.net,Jquery Ui,Postback,Accordion,我环顾四周,找到了许多解决方案,但出于某种原因,这对我来说根本不起作用 .NET 4,c# 我有一架有三节的手风琴。在我的c#代码隐藏加载部分中,我有 if (!IsPostBack) { MembershipUser websiteUser = Membership.GetUser(); ProfileCommon websiteUserProfile = Profile.GetProfile(websiteUser.UserName); if (websiteUse
if (!IsPostBack)
{
MembershipUser websiteUser = Membership.GetUser();
ProfileCommon websiteUserProfile = Profile.GetProfile(websiteUser.UserName);
if (websiteUserProfile.PrimaryCompany == "BEL")
hiddenAccordionIndex.Value = "1";
}
这将设置初始活动部分。这个很好用
我现在想做的是,如果活动部分切换为0,然后页面上发生回发,我希望手风琴将活动部分保持为0
实际发生的是,手风琴正在切换回1
我的jquery
var currentIndex = $("#<%= hiddenAccordionIndex.ClientID %>").val();
$("#accordion").accordion({
heightStyle: "content",
collapsible: true,
active: parseInt(currentIndex),
change: function (event, ui) {
var newIndex = $(this).children("h3").index(ui.newHeader);
$("#<%= hiddenAccordionIndex.ClientID %>").val(newIndex);
}
});
var currentIndex=$(“#”)val();
$(“手风琴”)。手风琴({
高度样式:“内容”,
可折叠的:是的,
活动:parseInt(当前索引),
更改:功能(事件、用户界面){
var newIndex=$(this.children(“h3”).index(ui.newHeader);
$(“#”)val(新索引);
}
});
即使我删除了设置初始活动部分的c#代码,行为也是一样的。所以我确信这不是问题的原因
有人能提出这里可能出了什么问题吗?我被难住了
谢谢,我有答案了
更改不是一个事件。相反,我使用了激活,现在可以使用了
我看到的所有解决方案都是一个更改事件,也许这是针对旧版本的
新代码
var currentIndex = $("#<%= hiddenAccordionIndex.ClientID %>").val();
$("#accordion").accordion({
heightStyle: "content",
collapsible: true,
active: parseInt(currentIndex),
activate: function (event, ui) {
var newIndex = $(this).children("h3").index(ui.newHeader);
$("#<%= hiddenAccordionIndex.ClientID %>").val(newIndex);
}
});
var currentIndex=$(“#”)val();
$(“手风琴”)。手风琴({
高度样式:“内容”,
可折叠的:是的,
活动:parseInt(当前索引),
激活:功能(事件、用户界面){
var newIndex=$(this.children(“h3”).index(ui.newHeader);
$(“#”)val(新索引);
}
});