if (state.cur && state.cur.id === id) { state.cur=null; $("#recsCard").style.display="none"; } await loadLists(); }); }); $("#recBody").addEventListener("click", async (e) => { const b = e.target.closest("button"); if (!b || !b.dataset.delrec) return; await api(`/recipients/${b.dataset.delrec}`, { method:"DELETE" }); toast("Recipient deleted", "ok"); await loadRecs(); await loadLists(); }); $("#pager").addEventListener("click", (e) => { const b = e.target.closest("button"); if (!b || b.disabled) return; state.page = +b.dataset.pg; loadRecs(); });