早上好。
我有一个模式 JQuery 对话框,在打开调用并加载部分视图时。https://stackoverflow.com/a/4802423/1193841 这里可以看到很好的例子,但我会重新粘贴:
<script type="text/javascript">
$(function () {
$('#dialog').dialog({
autoOpen: false,
width: 400,
resizable: false,
title: 'hi there',
modal: true,
open: function(event, ui) {
//Load the CreateAlbumPartial action which will return
// the partial view _CreateAlbumPartial
$(this).load("@Url.Action("CreateAlbumPartial")");
},
buttons: {
"Close": function () {
$(this).dialog("close");
}
}
});
$('#my-button').click(function () {
$('#dialog').dialog('open');
});
});
在我的例子中,ActionMethod "CreateAlbumPartial" 采用一个 ID 参数,该参数使用 onclick=" 事件从另一个页面传递。
如何使该 ID 在调用时可传递给操作方法,如上所示?类似的东西
$('#dialog').dialog('open',Id)
会很棒,但我不认为这就是它的工作原理。
附言现在我通过执行 $.post(( 将.html(数据(加载到div 然后在 .show((.dialog('open'( 中显示该 DIV,来显示我的弹出窗口。但是,与其将我的 Action 方法调用和 Dialog 相关内容分开,我真的很想按照我要求将所有逻辑保存在一个地方的方式重新做它。
提前谢谢你。
为什么不创建一个隐藏的控件并为其赋值并在对话框中使用它