Skip to content

Commit 9f48e1c

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

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
@@ -271,6 +271,28 @@ function editRecord() {
271271
}
272272

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

276298
function restoreRecord() {

0 commit comments

Comments
 (0)