我有一个绑定到视图模型的视图。在那个视图上,我有一个链接,它将弹出一个模态 jquery 对话框(使用部分视图)。
我需要的是能够将模型传递给模型弹出窗口,对其进行更新,然后将其传递回视图页面。
我在我的控制器(部分视图)中加载了带有操作方法的模式弹出窗口。但努力将模型传递给它。
有什么建议么?
提前非常感谢。
脚本(在查看页面上):
// ZipLocator modal popup
$(function () {
$('#ZipLocatorDialog').dialog({
autoOpen: false,
width: 400,
resizable: false,
draggable: false,
title: 'hi there',
modal: true,
show: { effect: 'blind' },
open: function (event, ui) {
// Load the ZipLocator action which will return the partial view _ZipLocator
$(this).load('@Url.Action("ZipLocator", "Shop", New With { .area = "Shop"})');
},
buttons: {
"Close": function () {
$(this).dialog('close');
}
}
});
$('#ZipLocatorOpener').click(function () {
$('#ZipLocatorDialog').dialog('open');
});
});
部分视图的控制器操作:
<HttpGet()>
<Compress()>
Public Function ZipLocator(model As ShopModel) As ActionResult
Return PartialView("~/Areas/Shop/Views/Shared/Partials/Popups/_ZipLocator.vbhtml", model)
End Function
正如我所说,jQuery 模态弹出窗口正在工作,我只是很难将我的模型传递给它。
第一步是将模型传递给局部视图(jQuery modal popup)。第二步是在对话框关闭后将更新的模型传回视图。