From 7daf75044a23b1b243544a631b30d01ae4773e99 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Wed, 27 Sep 2023 19:13:22 -0300 Subject: [PATCH] Passing the type using the `data-type` attribute Fix the "Cannot read properties of undefined" error: - The `function editAdlist(event)` wasn't receiving any arguments, because every call to this function is not passing arguments, so `event` was undefined. Using `data-type` attribute to pass the value and avoid the error. Signed-off-by: RD WebDesign --- scripts/pi-hole/js/groups-adlists.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index e2d0c47b1..84ff709c2 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -146,6 +146,7 @@ function initTable() { rowCallback: function (row, data) { var dataId = utils.hexEncode(data.address); $(row).attr("data-id", dataId); + $(row).attr("data-type", data.type); var statusCode = 0, statusIcon; @@ -534,10 +535,10 @@ function addAdlist(event) { }); } -function editAdlist(event) { - const type = event.data.type; +function editAdlist() { const elem = $(this).attr("id"); const tr = $(this).closest("tr"); + const type = tr.attr("data-type"); const address = tr.attr("data-id"); const status = tr.find("#enabled_" + address).is(":checked"); const comment = utils.escapeHtml(tr.find("#comment_" + address).val());