2015-10-06 58 views
-1

我需要你的幫助來幫助我的jquery模式顯示我的控制器返回的操作結果。JQuery模式不顯示

在我的劇本,這裏是代碼:

<script type="text/javascript"> 
$(document).ready(function() { 
    $("#dialog-detail").dialog({ 
     title: 'View Details', 
     autoOpen: false, 
     resizable: false, 
     width: 400, 
     show: { effect: 'drop', direction: "up" }, 
     modal: true, 
     draggable: true, 
     open: function (event, ui) { 
      $(".ui-dialog-titlebar-close").hide(); 
      $(this).load(url); 
     }, 
     buttons: { 
      "Close": function() { 
       $(this).dialog("close"); 
      } 
     } 
    }) 


    $(".lnkDetail").live("click", function (e) { 
     // e.preventDefault(); use this or return false 
     url = $(this).attr('href'); 
     $("#dialog-detail").dialog('open'); 

     return false; 
    }); 
}); 

而且在查看部分:

@foreach(var rfp in Model){ 
    <tr> 
     <td> 

       @Html.ActionLink("Details", "Details", new { rf_id = rfp.rf_id }, new { @class = "lnkDetail" }) 
       <div id="dialog-detail" style="display: none"></div> 
     </td> 
    </tr> 
    } 

而在我的控制,這是返回的視圖代碼使用模態內的id。

public ActionResult Details(int rf_id = 0) 
    { 
     var check = db.rms_approval_route_vw.Where(s => s.rf_id == rf_id).FirstOrDefault(); 

     if (check != null) 
     { 
      return PartialView(check); 
     } 
     else { 
      ViewBag.message = "Waiting for regularization."; 
     } 

     return PartialView(); 
    } 

我已經在我的佈局中加載了jquery ui庫。當我試圖運行代碼時,它不顯示模式。

任何想法爲什麼會發生這種情況? 我真的需要你的幫助。

非常感謝。

+1

什麼是它沒有顯示?請編輯您的問題標題。 – www139

+0

模態,它沒有顯示。 –

回答

1

查看

@foreach(var rfp in Model){ 
     <tr> 
      <td> 

        <a onclick="ShowPopup(@rfp.rf_id)">Details</a> 

      </td> 
     </tr> 
     } 
    <div id="dialog-detail" style="display: none"></div> 

腳本

<script type="text/javascript"> 
$(document).ready(function() { 
    $("#dialog-detail").dialog({ 
     title: 'View Details', 
     autoOpen: false, 
     resizable: false, 
     width: 400,    
     modal: true, 
     draggable: true, 
     open: function (event, ui) {    
     }, 
     buttons: { 
      "Close": function() { 
       $(this).dialog("close"); 
      } 
     } 
    }) 


}); 
function ShowPopUp(id) { 
    $('#dialog-detail').load('Details/?rf_id='+id, function() { 
    $.validator.unobtrusive.parse($("#dialog-detail")); 
    $('#dialog-detail').dialog('open'); 
    $('#dialog-detail').dialog('option', 'title', 'View Details'); 
});} 
</script> 

行動

public ActionResult Details(int rf_id = 0) 
    { 
     var check = db.rms_approval_route_vw.Where(s => s.rf_id == rf_id).FirstOrDefault(); 

     if (check != null) 
     { 
      return PartialView(check); 
     } 
     else { 
      ViewBag.message = "Waiting for regularization."; 
     } 

     return PartialView(); 
    } 
+0

腳本中的id在哪裏? –

+1

@IamGlads請看正確的一個 – Rakin

+1

謝謝@Rakin –