【发布时间】:2017-09-01 06:37:08
【问题描述】:
在我的应用程序中,如果我没有点击保存并想从当前页面导航,它应该询问甜蜜警报are you sure want to leave? 和两个按钮save and leave。我该怎么做。
目前我正在使用 jquery,当我单击任何锚标记但立即导航到其他页面时,它会显示 sweetalert 框。
我的代码是
jQuery(document).click(function(e) {
if (jQuery(e.target).is('a')) {
swal({
title: "Are you sure?",
text: "Want to continue without saving?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Leave",
closeOnConfirm: false,
html: false
}
);
}
});
【问题讨论】:
-
看看
preventDefault()...
标签: javascript jquery angularjs