-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
//--- 編集内容がある場合にブラウザバック防止
let isFormDirty = false;
// ページ離脱前に警告
window.addEventListener("beforeunload", function (e) {
if (isFormDirty) {
e.preventDefault();
e.returnValue = ""; // Chrome 用
}
});
// 入力フォームに変化があれば dirty フラグを立てる
document.querySelectorAll("#nuForm input, #nuForm textarea, #nuForm select").forEach(el => {
el.addEventListener("change", () => {
isFormDirty = true;
});
el.addEventListener("input", () => {
isFormDirty = true;
});
});
ここら辺の監視をモジュール化する
→nu.dirty(function() {})
→nu.dirty.clear();
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels