table click event controlled for responsive

This commit is contained in:
Burak Civan 2022-06-07 15:23:37 +03:00
parent d1f987c720
commit 5079d52cce

View File

@ -11,20 +11,21 @@ document.querySelectorAll("[data-table-list]").forEach((row) => {
//redirect edit or show page for table row click //redirect edit or show page for table row click
document.querySelectorAll("[data-table-body]").forEach((table) => { document.querySelectorAll("[data-table-body]").forEach((table) => {
if (document.body.clientWidth >= 991) {
let rows = table.querySelectorAll("tr"); let rows = table.querySelectorAll("tr");
rows.forEach((row) => { rows.forEach((row) => {
let row_href = row.getAttribute("href"); let row_href = row.getAttribute("href");
if (! row_href) { if (!row_href) {
return; return;
} }
let td = row.getElementsByTagName("td"); let td = row.getElementsByTagName("td");
let first_selector = row.querySelector('[data-bulkaction]') && row.querySelector('[data-bulkaction]') !== null ? 1 : 0; let first_selector = row.querySelector("[data-bulkaction]") && row.querySelector("[data-bulkaction]") !== null ? 1 : 0;
if (row_href) { if (row_href) {
for (let i=first_selector; i<td.length-1; i++) { for (let i = first_selector; i < td.length - 1; i++) {
let td_item = td[i]; let td_item = td[i];
td_item.addEventListener("click", () => { td_item.addEventListener("click", () => {
window.location.href = row_href; window.location.href = row_href;
@ -32,6 +33,7 @@ document.querySelectorAll("[data-table-body]").forEach((table) => {
} }
} }
}); });
}
}); });
//redirect edit or show page for table row click //redirect edit or show page for table row click