lc.js 788 B

123456789101112131415161718192021222324252627
  1. function confirmDelete(url, id) {
  2. if ($(`#confirm_${id}`).length > 0) {
  3. return;
  4. }
  5. let link = $(`#delete_${id}`);
  6. let confirm = link.append(
  7. `<span class="deleteconfirm" id="confirm_${id}">Are you sure?
  8. <a id="do_delete_${id}">yes</a>
  9. <a id="cancel_delete_${id}">no</a>
  10. </span>`);
  11. $(document).on('click', `a#do_delete_${id}`, function() {
  12. var req = new XMLHttpRequest();
  13. req.addEventListener("load", function() {
  14. $(`#link_${id}`).remove();
  15. });
  16. req.open("DELETE", url);
  17. req.send();
  18. });
  19. $(document).on('click', `a#cancel_delete_${id}`, function() {
  20. $(`#confirm_${id}`).remove();
  21. });
  22. }
  23. function removeConfirm(id) {
  24. $(`#confirm_${id}`).remove();
  25. }