|
151 | 151 | } |
152 | 152 | } |
153 | 153 |
|
154 | | - // Style old table |
| 154 | + const styleTable = (mutationList, observer) => { |
| 155 | + if ($("#val_table tr td").first().attr("colspan") == "4") return // Already styled |
| 156 | + $("#val_table tr td").first().attr("colspan", "4") |
| 157 | + $("#val_table tr:not(:first)").append(` |
| 158 | + <td class="data2" style="text-align:center;font-size:13px"> |
| 159 | + <a class="validationRemove hidden"> |
| 160 | + <i class="fa-solid fa-trash-can"></i> |
| 161 | + </a> |
| 162 | + </td> |
| 163 | + `) |
| 164 | + module.settings.emTypes.forEach((el) => $(`#${el} a`).removeClass('hidden')) |
| 165 | + }; |
| 166 | + |
| 167 | + // Style old table, watches for changes when enable/disable is clicked (Add delete buttons) |
155 | 168 | $("head").append(`<style>${css}</style>`) |
156 | | - $("#val_table tr td").first().attr("colspan", "4") |
157 | | - $("#val_table tr:not(:first)").append(` |
158 | | - <td class="data2" style="text-align:center;font-size:13px"> |
159 | | - <a class="validationRemove hidden"> |
160 | | - <i class="fa-solid fa-trash-can"></i> |
161 | | - </a> |
162 | | - </td> |
163 | | - `) |
164 | | - module.settings.emTypes.forEach((el) => $(`#${el} a`).removeClass('hidden')) |
| 169 | + const observer = new MutationObserver(styleTable) |
| 170 | + observer.observe($("#val_table").get(0), { childList: true, subtree: true }) |
| 171 | + styleTable() |
165 | 172 |
|
166 | 173 | // Insert the new form and setup |
167 | 174 | $("#val_table").before(html).show() |
|
194 | 201 | }) |
195 | 202 | }) |
196 | 203 |
|
197 | | - // Setup old table Interactivity (delete) |
| 204 | + // Setup old table Interactivity (Delete functionality) |
198 | 205 | $("#val_table").on("click", ".validationRemove", (el) => { |
199 | 206 | const $el = $(el.currentTarget) |
200 | 207 | const $row = $el.closest('tr') |
|
0 commit comments