在我的应用程序,如果我因此未单击保存,想从当前页面导航应该问甜蜜警报are you sure want to leave?
和两个按钮save and leave
。我怎样才能做到这一点。SweetAlert而导航到
目前我使用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()'... – hallleron