I have a jQuery accordion in a page in ASP:Net MVC application in which I want to set the active accordion at runtime.
IMy code is as follows:
<script type="text/javascript">
$(document).ready(function() {
var accordionindex = $("#UIPViewModel_ActiveAccordion").val();
alert("Setting active index to " + accordionindex);
$("#accordion").accordion('activate', accordionindex );
});
</script>
You will see the last line sets the active accordion. When I use this code it always acts like I have used active : false and ALL of the accordions are closed even though the alert displays the correct runtime value.
I have also tried simply using the following which is the same:
$("#accordion").accordion('activate', $("#UIPViewModel_ActiveAccordion").val());
When I change the last line to :
$("#accordion").accordion('activate', 2 ); (i.e. hard-coded). It always works correctly!
Can anyone see what´s wrong?