所以目前,我有页面加载这个:
<div class="accordion">
<h2><a href="#">Pending Flyers</a></h2>
<div id="flyers-0" class="accordion-item"><% Html.RenderPartial("ManageFlyers", new { flyers = pendingFlyersWithCategory }); %></div>
<h2><a href="#">Approved Flyers</a></h2>
<div id="flyers-1" class="accordion-item"><% Html.RenderPartial("ManageFlyers", new { flyers = approvedFlyersWithCategory }); %></div>
<h2><a href="#">Denied Flyers</a></h2>
<div id="flyers-2" class="accordion-item"><% Html.RenderPartial("ManageFlyers", new { flyers = deniedFlyersWithCategory }); %></div>
<h2><a href="#">Published Flyers</a></h2>
<div id="flyers-3" class="accordion-item"><% Html.RenderPartial("ManageFlyers", new { flyers = publishedFlyersWithCategory }); %></div>
<h2><a href="#">Expired Flyers</a></h2>
<div id="flyers-4" class="accordion-item"><% Html.RenderPartial("ManageFlyers", new { flyers = expiredFlyersWithCategory }); %></div>
</div>
用这个java脚本来做手风琴的东西:
<script language="javascript" type="text/javascript">
if ($('.accordion').length > 0) {
$('.accordion-item').hide();
$('.accordion-selected').show();
$('.accordion h2').click(function () {
$(this).next('.accordion-item').slideToggle('slow');
});
$('.accordion h2 a').click(function () {
var element = $(this).parent().next('.accordion-item');
element.slideToggle('slow');
return false;
});
}
</script>
<script type="text/javascript">
$(document).ready(function () {
// Accordian state restore
var accord = '<%= Session["accordianIndex"] %>';
var currentindex = 0;
if (accord != "") {
currentindex = accord;
}
$("#flyers-" + currentindex).slideToggle("slow");
// end Accordian state restore
});
$("div.description").expander({
slicePoint: 200
});
</script>
我想将其设置为使用 AJAX 加载部分视图并在手风琴的那部分展开时插入它们,以加快页面的初始加载。
我已经尝试过<%= Ajax.ActionLink ... %>
和 javascript 来加载它,但我无法让它工作。任何建议,将不胜感激。