我正在尝试在Bootstrap v3.3.5中打开模态对话框,但一直没有成功。当我点击链接时,什么也没有显示出来。
如果您能告诉我哪里做错了,我将不胜感激。
以下是部分的脚本代码:
这里是一个DIV:
如果您能告诉我哪里做错了,我将不胜感激。
以下是部分的脚本代码:
$('body').on('click', '.modal-link', function (e) {
e.preventDefault();
$(this).attr('data-target', '#modal-container');
$(this).attr('data-toggle', 'modal');
});
// Attach listener to .modal-close-btn's so that when the button is pressed the modal dialog disappears
$('body').on('click', '.modal-close-btn', function () {
$('#modal-container').modal('hide');
});
//clear modal cache, so that new content can be loaded
$('#modal-container').on('hidden.bs.modal', function () {
$(this).removeData('bs.modal');
});
$('#CancelModal').on('click', function () {
return false;
});
这里是一个DIV:
<div id="modal-container" class="modal fade"
tabindex="-1" role="dialog">
<div class="modal-content">
</div>
</div>
这里是打开该模态框的ActionLink(它被设计成按钮样式,但这并不重要,它仍然附有modal-link
类):
@Html.ActionLink("Approve Pending",
"Home", "ViewApprovalModal",
null, new { @class = "modal-link btn btn-success", style = "font-size: 17px;" })
最后,这是ActionLink在HomeController中调用的C#代码,它只返回模态框应显示的局部内容:
public ActionResult ViewApprovalModal() {
return PartialView("_ApprovalModal");
}
当我点击ActionLink时,什么也没有发生,而且在开发者控制台中也没有任何错误或任何其他警告,这就是为什么我感到困惑的原因。它只是什么也不做,没有错误。