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
xxxxxxxxxx
1
{{#each records}}
2
3
</br>
4
5
<p style="display:none;" id="id">{{id}}</p>
6
7
<button class="btn btn-danger pull-left" id="delete"> Delete Record </button>
8
9
{{/each}}
JavaScript
xxxxxxxxxx
1
document.getElementById("delete").onclick = async function() {
2
if (confirm("Are you sure you want to delete this session")) {
3
var i = document.getElementById("id").innerText
4
await deleteRecord("4YZjnDNPvl", i); // In this part add your delete function
5
location.reload();
6
7
}
8
};
We'd love to hear your feedback.