在我的應用程序,如果我因此未單擊保存,想從當前頁面導航應該問甜蜜警報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