Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tasks.forEach(task => {
- template += `
- <tr>
- <td>${task.id}</td>
- <td>
- <a href="#" class="task-item">
- ${task.name}
- </a>
- </td>
- <td>${task.description}</td>
- <td>
- <button value="${task.id}" class="task-delete btn btn-danger">
- Delete
- </button>
- </td>
- </tr>
- `
- });
- //script with the delete function
- $(document).on('click', '.task-delete', (e) => {
- console.log('FetchTaskCheckDelete1!');
- if(confirm('Are you sure you want to delete it?')) {
- const element = $(this)[0].activeElement.parentElement;
- var element2 = $(this).attr("value");
- const id = $(element).attr("id");
- console.log('FetchTaskCheckDelete2!');
- console.log(element);
- console.log(element2);
- console.log(id);
- $.post('task-delete.php', {id}, (response) => {
- fetchTasks();
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement