0

ID 및 제목이있는 작업 목록이 포함 된 패널이 있습니다. 간단한보기와 간단한 컨트롤러가 있습니다. 목록에서partialview 데이터로 팝업 만들기 asp.net mvc5

public ActionResult Index() 
    { 
     ViewBag.menuItem = "DashBoard"; 
     return View(db.jobs.ToList()); 

    } 

항목 : 함께 갈

[HttpGet] 
    public ActionResult Details (int jobID) 
    { 

     var details = db.details.Find(jobID); 
     return PartialView(details); 
    } 

단지 sandard보기 : 나는 세부 사항 컨트롤러를 만든

<li class="list-group-item"> @item.ID @item.Title</li> 

는 해당 작업의 부분보기를 표시합니다 . 스 캐 폴딩을 사용합니다.

ID와 일치하는 작업 세부 정보로 클릭하면 팝업 상자가 표시되는 작업 링크를 해당 목록에 추가 할 수 있습니까?

답변

0

팝업 상자는 모달입니까? 그럼 경우

변경 목록의이 부분

<li class="list-group-item"><a data-id="@item.ID" href="#">@item.Title</a></li> 

난 당신이 jQuery를하고 부트 스트랩을 사용하는 가정거야? 그렇지 않다면 아래 링크를 제공하고 체크 아웃 할 것입니다.

$('.list-group-item a').click(function(){ 
    //gets the id for the selected list item 
    var itemId = $(this).data("id"); 

    //performs an ajax call to the controller to get the details based on the id selected 
    $.ajax({ 
    url : 'your controller url', 
    type : 'POST', 
    data : { 
     'jobID' : itemId 
    }, 
    dataType:'json', 
    success : function(data) {    
     //append the results to your modal's body. 
     //$("modal selector").modal('show'); 
    }, 
    error : function(error) 
    { 
     //do something with the error 
    } 
    }); 
}); 

Bootstrap Modals 링크 및 jQuery