Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. tasks.forEach(task => {
  2. template += `
  3. <tr>
  4. <td>${task.id}</td>
  5. <td>
  6. <a href="#" class="task-item">
  7. ${task.name}
  8. </a>
  9. </td>
  10. <td>${task.description}</td>
  11. <td>
  12. <button value="${task.id}" class="task-delete btn btn-danger">
  13. Delete
  14. </button>
  15. </td>
  16. </tr>
  17. `
  18. });
  19.  
  20. //script with the delete function
  21. $(document).on('click', '.task-delete', (e) => {
  22. console.log('FetchTaskCheckDelete1!');
  23.  
  24. if(confirm('Are you sure you want to delete it?')) {
  25. const element = $(this)[0].activeElement.parentElement;
  26. var element2 = $(this).attr("value");
  27. const id = $(element).attr("id");
  28.  
  29. console.log('FetchTaskCheckDelete2!');
  30. console.log(element);
  31. console.log(element2);
  32. console.log(id);
  33.  
  34. $.post('task-delete.php', {id}, (response) => {
  35. fetchTasks();
  36. });
  37. }
  38. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement