How to add Delete Functionality Inside a Modal
Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add this functionality is through the plugin installation wizard. Learn more about plugins here.
Here’s a way to add the delete functionality inside an edit popup modal.
Step 1
Create a table with an “Edit” link.
Step 2
Add a custom component to the edit page.
Step 3
Add custom code to the template and JavaScript.
Template
{{#each records}}
</br>
<p style="display:none;" id="id">{{id}}</p>
<button class="btn btn-danger pull-left" id="delete"> Delete Record </button>
{{/each}}
JavaScript
document.getElementById("delete").onclick = async function() {
if (confirm("Are you sure you want to delete this session")) {
var i = document.getElementById("id").innerText
await deleteRecord("4YZjnDNPvl", i); // In this part add your delete function
location.reload();
}
};
We'd love to hear your feedback.