From 6dde3fa88e7df0d7d2fc06747efb22277bdba76c Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Sun, 4 Feb 2024 01:24:04 -0300 Subject: [PATCH] Add function to save edited values Signed-off-by: RD WebDesign --- scripts/pi-hole/js/settings-dns.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/pi-hole/js/settings-dns.js b/scripts/pi-hole/js/settings-dns.js index 813639f9c..e0ac6200d 100644 --- a/scripts/pi-hole/js/settings-dns.js +++ b/scripts/pi-hole/js/settings-dns.js @@ -272,6 +272,28 @@ function editRecord() { } function saveRecord() { + // Find the row index + const index = $(this).attr("data-index"); + + // Get the edited values from each field + const values = []; + values[0] = $("#enabled_" + index).prop("checked") ? "true" : "false"; + values[1] = $("#network_" + index).val(); + values[2] = $("#ip_" + index).val(); + values[3] = $("#domain_" + index).val(); + + // Save the new values + // --- insert $.ajax() call to actually save the data + console.log(values.join(",")); + + // Finish the edition disabling the fields + $(this).closest("tr").find("td input").prop("disabled", true); + + // Show EDIT and DELETE buttons. Hide SAVE and UNDO buttons + $(this).siblings('[id^="edit"]').show(); + $(this).siblings('[id^="delete"]').show(); + $(this).hide(); + $(this).siblings('[id^="cancel"]').hide(); } function restoreRecord() {