2011-11-07 54 views
0

jquery ui手風琴用於導航ASP.net MVC2 site.master頁面。 手風琴面板包含單行菜單項。如何保持jquery ui手風琴點擊項目突出顯示,如果導航到其他頁面

如果某個列表項被點擊,新的頁面被加載,但手風琴會打開第一個面板。 如果打開新頁面,如何保持當前面板打開並點擊項目高亮顯示?

$("#accordion").accordion({ 
     fillSpace: true, 
     autoHeight: false, 
     navigation: true, 
    collapsible: true 
}); 



<h3> 
    <a href="#">menugroup1</a></h3> 
    <div> 
     <ul> 
      <li><a target='DoklstlG' href='xxxxxx'> 
       item1</a></li> 
      <li><a target='DoklstlO' href='yyyyy'>item2</a></li> 
      <li><a target='UnpaidG' href='zzzzzzz'>item3</a></li> 
      <li>&nbsp;</li> 
... 
     </ul> 
    </div> 

<h3> 
    <a href="#">menugroup2</a></h3> 
<ul> 
    <li><a target='DoklstlVL' href='nnnnnnnn'>menuitem21</a></li> 
    <li><a target='DoklstlSL' href='mmmmmmmmmm'>menuitem22</a></li> 
... 

回答

0

我希望這有助於!

<script> 
    $(function() { 
     var activeIndex = parseInt($('#AccordionIndex').val()); 

     $("#accordion").accordion({ 
      collapsible: true, 
      active: activeIndex, 
      event: "mousedown", 
      change: function (event, ui) { 
       var index = $(this).children('h3').index(ui.newHeader); 
       $('#AccordionIndex').val(index);     
      } 
     }); 
    }); 


</script> 
@using (Html.BeginForm()) 
     { 
      <input type=hidden id="AccordionIndex" name="AccordionIndex" [email protected] /> 
<input type="submit" value="Save Changes" /> } 

當提交被點擊時,一個控制器被設置爲接收一個[HTTP-POST], 返回在ViewBag.AccordionIndex 例如該值:

[HttpPost]  
public ActionResult MacSerialCheck(string index, string AccordionIndex) { 
if (AccordionIndex == ""){ 
ViewBag.AccordionIndex="0"; 
} 
else{ 
ViewBag.AccordionIndex=AccordionIndex; 
} 
相關問題