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