fix redirect back with params menu id

This commit is contained in:
arifal
2025-03-12 17:52:11 +07:00
parent 68ffc1c090
commit b0d4d4c23b
7 changed files with 52 additions and 34 deletions

View File

@@ -6,6 +6,7 @@ class CreateMenu {
initCreateMenu() {
const toastNotification = document.getElementById("toastNotification");
const toast = new bootstrap.Toast(toastNotification);
let menuId = document.getElementById("menuId").value;
document
.getElementById("btnCreateMenus")
.addEventListener("click", async function () {
@@ -41,7 +42,7 @@ class CreateMenu {
result.message;
toast.show();
setTimeout(() => {
window.location.href = "/menus";
window.location.href = `/menus?menu_id=${menuId}`;
}, 2000);
} else {
let error = await response.json();

View File

@@ -31,6 +31,7 @@ class Menus {
tableContainer.innerHTML = "";
let canUpdate = tableContainer.getAttribute("data-updater") === "1";
let canDelete = tableContainer.getAttribute("data-destroyer") === "1";
let menuId = tableContainer.getAttribute("data-menuId");
this.table = new Grid({
columns: [
@@ -47,7 +48,7 @@ class Menus {
if (canUpdate) {
buttons += `
<a href="/menus/${cell}/edit" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
<a href="/menus/${cell}/edit?menu_id=${menuId}" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
<i class='bx bx-edit'></i>
</a>
`;

View File

@@ -6,6 +6,7 @@ class UpdateMenu {
initUpdateMenu() {
const toastNotification = document.getElementById("toastNotification");
const toast = new bootstrap.Toast(toastNotification);
let menuId = document.getElementById("menuId").value;
document
.getElementById("btnUpdateMenus")
.addEventListener("click", async function () {
@@ -41,7 +42,7 @@ class UpdateMenu {
result.message;
toast.show();
setTimeout(() => {
window.location.href = "/menus";
window.location.href = `/menus?menu_id=${menuId}`;
}, 2000);
} else {
let error = await response.json();