so currently i have a page loading this:
<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>
with this java script to make accordion material:
<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 () {
var accord = '<%= Session["accordianIndex"] %>';
var currentindex = 0;
if (accord != "") {
currentindex = accord;
}
$("#flyers-" + currentindex).slideToggle("slow");
});
$("div.description").expander({
slicePoint: 200
});
</script>
I want to configure it to use AJAX to load partial views and insert them when this part of the accordion is expanded to speed up the initial loading of the page.
I tried both <%= Ajax.ActionLink ... %>and javascript to load it, but I can't get it to work. Any suggestions would be appreciated.
source
share