我意识到这个问题有点宽泛,但我希望我能够提供足够的上下文细节来缩小范围。在我很新的项目中,我的任务之一是在用户点击注销链接时添加确认对话框。我在_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没有任何关系,因为角度只会在这个布局中的某些正文视图中出现,但是它被加载了,我有点担心我的jQuery可能引入的任何副作用。
答案 0 :(得分:0)
是,这是安全的。我假设模态本身没有任何角度逻辑。即使有,你也必须故意试图干扰Angular,以便发生任何副作用。