【发布时间】:2015-05-09 07:10:15
【问题描述】:
我意识到这个问题有点宽泛,但我希望我能提供足够的上下文细节来缩小范围。在我非常陌生的项目中,我的任务之一是在用户单击注销链接时添加确认对话框。我已将链接更改如下,在_Layout.cshtml:
<div class="row inner">
@if (Request.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { @id = "logoutForm", @class = "col-md-8 col-md-offset-2 rightText" }))
{
@Html.AntiForgeryToken()
<a href="@Url.Action("CreateNewMlamApplication", "MlamApplication")"><img src="/img/icons/plusIcon.png" class="icon" /></a>
<a href="@Url.Action("Index", "Home")"><img src="/img/icons/documentIcon.png" class="icon" /></a>
@* BKMOD <a href="javascript:document.getElementById('logoutForm').submit()"><img src="/img/icons/gearIcon.png" class="icon" /></a>*@
<a class="logout-link-confirm" href="#" ><img src="/img/icons/gearIcon.png" class="icon" /></a>
}
}
</div>
然后,我将一个处理程序连接到布局底部的logout-link-confirm:
<script>
$(function() {
$(".logout-link-confirm").click(function() {
$('#modalLogoutConfirmation').modal('show');
});
$(".logout-link-final").click(function () {
$('#logoutForm').submit()
});
});
</script>
@RenderSection("scripts", required: false)
</body>
在modalLogoutConfirmation 弹出窗口中,当用户确认他们的选择时,我执行实际注销:$('#logoutForm').submit()。
这与 angular 没有直接关系,因为 angular 仅在此布局中的某些 body 视图中起作用,但它已加载,我有点担心我的 jQuery 可能引入的任何副作用。
【问题讨论】:
-
你为什么不使用 modal "directive from angular Ui team 而不是 Jquery?
-
@sani,因为注销按钮和模式超出了“环境”角度应用程序的范围,我宁愿不引入第二个应用程序或干预主应用程序的范围。跨度>
标签: jquery asp.net-mvc angularjs