class DocumentPage { static InitItemsSection() { const $table = $("#document-items-section table"); const $checkboxes = $table.find("input[type=checkbox]"); const $allCheckbox = $("#all-items-checkbox"); $allCheckbox.on("change", () => { const checked = $allCheckbox.prop("checked"); $checkboxes.prop("checked", checked); }); $table.find(".btn-delete-document-item").on("click", event => { const documentItemId = $(event.currentTarget).data("document-item-id"); const confirmed = confirm("Are you sure you want to delete this item?"); if(confirmed) { $.post(window.location + "/delete-item", { document_item_id: documentItemId }).then(response => { toastr.success("Item deleted successfully."); $("#document-items-section").html(response.html); DocumentPage.InitItemsSection(); }); } }); } } $(() => { DocumentPage.InitItemsSection(); });