ASP.NET MVC在弹出窗口中加载局部视图

maz*_*ztt 2 asp.net asp.net-mvc

如何在jQuery的弹出窗口中加载页面或部分视图?我正在使用jQuery弹出窗口,但它没有加载JavaScript.

Cra*_*ntz 13

要将其加载到占位符:

$("#idOfPartialViewContainerOnPage").load("/ControllerName/PartialViewName");
Run Code Online (Sandbox Code Playgroud)

Action的行为类似于:

public ActionResult PartialViewName() 
{
    return PartialView(GetModelForMyPartialView());
}
Run Code Online (Sandbox Code Playgroud)

要使其成为弹出窗口,请使用类似jQuery UI对话框的内容:

var ph = $("#idOfPartialViewContainerOnPage");
ph.load("/ControllerName/PartialViewName", function() { 
    ph.dialog({
        // set dialog options here
    });
});
Run Code Online (Sandbox Code Playgroud)