2013-07-30 37 views
2

我有一個鏈接表的視圖。當鏈接被點擊時,jQuery通過ajax加載一個PartialViewResult。問題是當用戶單擊部分視圖中顯示的結果中的鏈接並轉到另一個頁面,然後單擊後退按鈕時,頁面上原始頁面上呈現的局部視圖的內容不再存在。如果用戶單擊瀏覽器後退按鈕,如何顯示呈現的局部視圖?點擊瀏覽器後退按鈕,部分視圖不再顯示?

JQuery的...

<script type="text/javascript"> 

function getGroup(id) { 
    var link = "Search/GroupDetails/" + id; 
    $('#Group').load(link); 
    $('#Group').show(); 
} 

這是加載到DIV

<div id="Group"> 
</div> 

控制器管窺

 public PartialViewResult GroupDetails(string id) 
    { 
     SearchIndexViewModel newSIVM = new SearchIndexViewModel(); 
     id = Help.FormatID(id); 
     CCRUser ccrUser = _CCRUser.GetUser(); 
     newSIVM.CCRUser = ccrUser; 

     if (!string.IsNullOrEmpty(id)) 
     { 
      newSIVM.Selected_Group = _Groups.GetSingleGroup(id, cUser); 
      newSIVM.Group_Owner = _Groups.GetGroupOwner(id, cUser); 
      newSIVM.Group_Members = _Groups.GetGroupMembers(id, cUser);   
      HttpContext.Session["SELECTEDGROUPNAME"] = id; 

     } 

     return PartialView("_GroupDetails", newSIVM); 
    } 
+0

任何援助將不勝感激。 :) –

回答

0

你可以有一個的document.ready功能在你的sc RIPT。每當您加載原始視圖時,它都會被觸發。 (我檢查,即使你按後退按鈕,它會被解僱)

$(document).ready(function() { 
    // Check the session value from the server by sending a ajax request. 
    // You can use the success function of the ajax request to call the get group function 
    // If a SELECTEDGROUPNAME exists 
    getGroup(1); 

}); 
相關問題