asp.net mvc - Jquery Accordion Closes during mvc.Pagelist next page event -



asp.net mvc - Jquery Accordion Closes during mvc.Pagelist next page event -

i have jquery accordion, works fine, within mvc.pagedlist, happens when nail next button within it, page reloads , accordion window close.. tried adding next codes create workaround seem cant create work..

controller // method

if (page != null) { viewbag.paneltoopen = 0; }

view

@section scripts { <script> var searchinputs = $("#searchcriteria1").find("input[type=text], select"); var emptyfields = 0; searchinputs.each(function () { if (!$(this).val()) { emptyfields++; } }); if (emptyfields == searchinputs.length) { $("#searchcriteria1").accordion({ active: false, collapsible: true }); } else { $("#searchcriteria1").accordion({ //active: false, collapsible: true }); } </script> @if (viewbag.paneltoopen == 0) { <script> $("#searchcriteria1").accordion({ active: true, collapsible: true }); </script> } }

to accomplish should set .accordion("option", "active","activepanelindex") click link see docs

and here working fiddle javascript should alter below

@section scripts { <script> $(function () { var activepanelindex = "@viewbag.paneltoopen", accordioncontainer = $("#searchcriteria1"), searchinputs = $(":text, select", accordioncontainer), emptyfields = searchinputs.filter(function () { homecoming !!$(this).val(); }).length; accordioncontainer.accordion({ active: false, collapsible: true }); if (!activepanelindex || emptyfields != searchinputs.length) { accordioncontainer.accordion("option", "active", number(activepanelindex) || 0); } }) </script> }

jquery asp.net-mvc jquery-accordion pagedlist

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -