所以目前,我有網頁加載這樣的:如何在ASP.NET應用程序的加載區中加載部分視圖?
<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加載它,但我不能得到它的工作。任何建議,將不勝感激。
確保您指定的標籤正確的技術,在這種情況下是'ASP.NET MVC'。 –