diff options
-rw-r--r-- | pyaggr3g470r/templates/home.html | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index 2c9460df..3db5eb87 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -98,7 +98,7 @@ <td><a href="/article/{{ article.id }}">{{ article.title|safe }}</a></td> <td class="date">{{ article.date|datetime }}</a></td> <td> - <a href="/delete/{{ article.id }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this article') }}"></i></a> + <a href="#"><i class="glyphicon glyphicon-remove delete" title="{{ _('Delete this article') }}"></i></a> <a href="#"> {% if article.like %} <i class="glyphicon glyphicon-star like" title="{{ _('One of your favorites') }}"></i> @@ -136,7 +136,6 @@ <script type="text/javascript" class="source"> $(document).ready(function() { - // Like or unlike an article $('.like').on('click', function() { var article_id = $(this).parent().parent().parent().attr("data-article"); @@ -173,7 +172,23 @@ $(document).ready(function() { }); // ajax closed }); -}) + // Delete an article + $('.delete').on('click', function() { + var article_id = $(this).parent().parent().parent().attr("data-article"); + $(this).parent().parent().parent().remove(); + // sends the updates to the server + $.ajax({ + type: 'DELETE', + url: "/api/v1.0/articles/"+article_id, + success: function (result) { + //console.log(result); + }, + error: function(XMLHttpRequest, textStatus, errorThrown){ + console.log(XMLHttpRequest.responseText); + } + }); // ajax closed + }); +}) </script> {% endblock %} |