Guest User

Untitled

a guest
Jul 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <a class="delCommentLink" href="{% url 'article:comment_delete' comment.id %}">
  2. <span id="{{ comment.id }}" class="glyphicon glyphicon-trash" aria-hidden="true">delete</span>
  3. </a>
  4.  
  5. $(document).ready(function () {
  6. $("body").on("click",".delCommentLink",function (e) {
  7. e.preventDefault();
  8. var comment_url = $(e.target).parent().attr("href");
  9. var $commentEle = $(e.target).closest(".comment");
  10. if (window.confirm("Delete this comment?")) {
  11. $.ajax({
  12. type: "get",
  13. url: comment_url,
  14. success: function (data) {
  15. var ret = JSON.parse(data);
  16. if (ret['status'] == 1) {
  17. $commentEle.hide();
  18. } else {
  19. alert(ret['msg']);
  20. };
  21. },//success
  22. });//ajax
  23. } else {
  24. e.preventDefault()
  25. }
  26. });//click event
  27. })
Add Comment
Please, Sign In to add comment