Skip to content

Commit

Permalink
Add function to save edited values
Browse files Browse the repository at this point in the history
Signed-off-by: RD WebDesign <[email protected]>
  • Loading branch information
rdwebdesign committed Mar 19, 2024
1 parent bc13e17 commit 6dde3fa
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/pi-hole/js/settings-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 6dde3fa

Please sign in to comment.