Skip to content

Commit

Permalink
Passing the type using the data-type attribute
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rdwebdesign committed Sep 27, 2023
1 parent 60ed8d2 commit 7daf750
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/pi-hole/js/groups-adlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 7daf750

Please sign in to comment.