Skip to content

Commit c2fbc18

Browse files
committed
Add function to save edited values
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
1 parent 15d6396 commit c2fbc18

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

scripts/pi-hole/js/settings-dns.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,28 @@ function editRecord() {
272272
}
273273

274274
function saveRecord() {
275+
// Find the row index
276+
const index = $(this).attr("data-index");
277+
278+
// Get the edited values from each field
279+
const values = [];
280+
values[0] = $("#enabled_" + index).prop("checked") ? "true" : "false";
281+
values[1] = $("#network_" + index).val();
282+
values[2] = $("#ip_" + index).val();
283+
values[3] = $("#domain_" + index).val();
284+
285+
// Save the new values
286+
// --- insert $.ajax() call to actually save the data
287+
console.log(values.join(","));
288+
289+
// Finish the edition disabling the fields
290+
$(this).closest("tr").find("td input").prop("disabled", true);
291+
292+
// Show EDIT and DELETE buttons. Hide SAVE and UNDO buttons
293+
$(this).siblings('[id^="edit"]').show();
294+
$(this).siblings('[id^="delete"]').show();
295+
$(this).hide();
296+
$(this).siblings('[id^="cancel"]').hide();
275297
}
276298

277299
function restoreRecord() {

0 commit comments

Comments
 (0)