【发布时间】:2019-11-07 19:34:14
【问题描述】:
当一个单选按钮在多行表中被选中时,会触发 OnCheckedChanged 函数。每行代表一本书的详细信息。 “bn”参数是书号。
问题是我必须在模式中显示某个消息,但只有在我从操作方法 showBook 获得结果之后,因为要显示的消息取决于 bn 值。消息以模态显示后,如果用户选择删除图书,则需要调用新的action方法,我们需要再次将这个bn参数传递给另一个action方法。
如何将此 bn 传递给 modal 并再次传递给 modal 内部的 action 方法?我正在使用 Asp.net MVC,以防万一可以让事情变得更容易。
function OnCheckedChanged(bn) {
var url = "/book/showBook?bookNumber=" + bn;
$.get(url, function (result) {
$("#showBookModal").modal('show', function () {
//so now I need to tell the modal to display the details about the book,
//and the details are in a result, I don't know how to
});
});
}
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Book title</h4>
</div>
<div class="modal-body">
<p>display details about the book here</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-default" data-dismiss="modal">delete this book</button>
</div>
</div>
</div>
</div>
【问题讨论】:
-
听起来使用替代脚本会更容易,例如,使用fancybox (fancyboxjs.com) 你可以像
$.fancybox.open({type: 'html', src:'<p>Your HTML</p>'});那样做某事(fancybox 也可以为你做 ajax 请求)。 -
我可能不会添加其他库
标签: javascript asp.net model-view-controller modal-dialog