A one minute googling gave me a resolve to my question why Firefox was failing with a NetworkError. That's because I forgot about preventDefault()!
This commit is contained in:
parent
45c2ff6505
commit
db41e25c84
@ -5,6 +5,7 @@ function get_field(e, el) {
|
|||||||
// EDIT ENTRY
|
// EDIT ENTRY
|
||||||
|
|
||||||
function edit_entry(e) {
|
function edit_entry(e) {
|
||||||
|
e.preventDefault();
|
||||||
let data = new URLSearchParams();
|
let data = new URLSearchParams();
|
||||||
data.append("message", get_field(e.target, "message"));
|
data.append("message", get_field(e.target, "message"));
|
||||||
data.append("name", get_field(e.target, "name"));
|
data.append("name", get_field(e.target, "name"));
|
||||||
@ -21,6 +22,7 @@ for (const edit_entry_button of document.getElementsByName("edit-entry"))
|
|||||||
// DELETE ENTRY
|
// DELETE ENTRY
|
||||||
|
|
||||||
function delete_entry(e) {
|
function delete_entry(e) {
|
||||||
|
e.preventDefault();
|
||||||
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}`, {method:"DELETE"})
|
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}`, {method:"DELETE"})
|
||||||
.catch(e => console.log(e))
|
.catch(e => console.log(e))
|
||||||
.then(() => window.location = "/guestbook/admin");
|
.then(() => window.location = "/guestbook/admin");
|
||||||
@ -32,6 +34,7 @@ for (const delete_entry_button of document.getElementsByName("delete-entry"))
|
|||||||
// EDIT REPLY
|
// EDIT REPLY
|
||||||
|
|
||||||
function edit_reply(e) {
|
function edit_reply(e) {
|
||||||
|
e.preventDefault();
|
||||||
let data = new URLSearchParams();
|
let data = new URLSearchParams();
|
||||||
data.append("message", get_field(e.target, "message"));
|
data.append("message", get_field(e.target, "message"));
|
||||||
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method: "PATCH", body: data})
|
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method: "PATCH", body: data})
|
||||||
@ -45,6 +48,7 @@ for (const edit_reply_button of document.getElementsByName("edit-reply"))
|
|||||||
// DELETE REPLY
|
// DELETE REPLY
|
||||||
|
|
||||||
function delete_reply(e) {
|
function delete_reply(e) {
|
||||||
|
e.preventDefault();
|
||||||
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method:"DELETE"})
|
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method:"DELETE"})
|
||||||
.catch(e => console.log(e))
|
.catch(e => console.log(e))
|
||||||
.then(() => window.location = "/guestbook/admin");
|
.then(() => window.location = "/guestbook/admin");
|
||||||
@ -56,6 +60,7 @@ for (const delete_reply_button of document.getElementsByName("delete-reply"))
|
|||||||
// NEW REPLY
|
// NEW REPLY
|
||||||
|
|
||||||
function send_reply(e) {
|
function send_reply(e) {
|
||||||
|
e.preventDefault();
|
||||||
let data = new URLSearchParams();
|
let data = new URLSearchParams();
|
||||||
data.append("message", get_field(e.target, "message"));
|
data.append("message", get_field(e.target, "message"));
|
||||||
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method: "POST", body: data})
|
fetch(`/api/guestbook/${get_field(e.target, "entry_id")}/reply`, {method: "POST", body: data})
|
||||||
|
@ -3,6 +3,7 @@ function get_field(e, el) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function edit_post(e) {
|
function edit_post(e) {
|
||||||
|
e.preventDefault();
|
||||||
let data = new URLSearchParams();
|
let data = new URLSearchParams();
|
||||||
data.append("category", get_field(e.target, "category"))
|
data.append("category", get_field(e.target, "category"))
|
||||||
data.append("new-category", get_field(e.target, "new-category"))
|
data.append("new-category", get_field(e.target, "new-category"))
|
||||||
@ -18,6 +19,7 @@ for (const edit_post_button of document.getElementsByName("edit-post"))
|
|||||||
edit_post_button.addEventListener("click", edit_post);
|
edit_post_button.addEventListener("click", edit_post);
|
||||||
|
|
||||||
function delete_post(e) {
|
function delete_post(e) {
|
||||||
|
e.preventDefault();
|
||||||
fetch(`/api/mindflow/${get_field(e.target, "post-id")}`, {method:"DELETE"})
|
fetch(`/api/mindflow/${get_field(e.target, "post-id")}`, {method:"DELETE"})
|
||||||
.catch(e => console.log(e))
|
.catch(e => console.log(e))
|
||||||
.then(() => window.location = "/mindflow/admin");
|
.then(() => window.location = "/mindflow/admin");
|
||||||
@ -27,6 +29,7 @@ for (const delete_post_button of document.getElementsByName("delete-post"))
|
|||||||
delete_post_button.addEventListener("click", delete_post);
|
delete_post_button.addEventListener("click", delete_post);
|
||||||
|
|
||||||
document.getElementById("manage-categories").elements["add"].addEventListener("click", ev => {
|
document.getElementById("manage-categories").elements["add"].addEventListener("click", ev => {
|
||||||
|
ev.preventDefault();
|
||||||
let data = new URLSearchParams();
|
let data = new URLSearchParams();
|
||||||
data.append("name", get_field(ev.target, "name"));
|
data.append("name", get_field(ev.target, "name"));
|
||||||
fetch(`/api/mindflow-category`, {method: "POST", body: data})
|
fetch(`/api/mindflow-category`, {method: "POST", body: data})
|
||||||
@ -35,6 +38,7 @@ document.getElementById("manage-categories").elements["add"].addEventListener("c
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("manage-categories").elements["edit"].addEventListener("click", ev => {
|
document.getElementById("manage-categories").elements["edit"].addEventListener("click", ev => {
|
||||||
|
ev.preventDefault();
|
||||||
let data = new URLSearchParams();
|
let data = new URLSearchParams();
|
||||||
data.append("name", get_field(ev.target, "name"));
|
data.append("name", get_field(ev.target, "name"));
|
||||||
fetch(`/api/mindflow-category/${get_field(ev.target, "category")}`, {method: "PATCH", body: data})
|
fetch(`/api/mindflow-category/${get_field(ev.target, "category")}`, {method: "PATCH", body: data})
|
||||||
@ -43,6 +47,7 @@ document.getElementById("manage-categories").elements["edit"].addEventListener("
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("manage-categories").elements["delete"].addEventListener("click", ev => {
|
document.getElementById("manage-categories").elements["delete"].addEventListener("click", ev => {
|
||||||
|
ev.preventDefault();
|
||||||
fetch(`/api/mindflow-category/${get_field(ev.target, "category")}`, {method: "DELETE"})
|
fetch(`/api/mindflow-category/${get_field(ev.target, "category")}`, {method: "DELETE"})
|
||||||
.catch(e => console.log(e))
|
.catch(e => console.log(e))
|
||||||
.then(() => window.location = "/mindflow/admin");
|
.then(() => window.location = "/mindflow/admin");
|
||||||
|
Loading…
Reference in New Issue
Block a user