aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/templates
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-06-28 15:13:33 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-06-28 15:13:33 +0200
commit6bab4ba0ce3e20e09eaecb117f50efdda4cfe993 (patch)
treed6cca025f5e6462b01c106529f26e975e255c1a3 /pyaggr3g470r/templates
parentTry to star an article with a jQuery PUT call. (diff)
downloadnewspipe-6bab4ba0ce3e20e09eaecb117f50efdda4cfe993.tar.gz
newspipe-6bab4ba0ce3e20e09eaecb117f50efdda4cfe993.tar.bz2
newspipe-6bab4ba0ce3e20e09eaecb117f50efdda4cfe993.zip
Try to delete an article with a jQuery DELETE call.
Diffstat (limited to 'pyaggr3g470r/templates')
-rw-r--r--pyaggr3g470r/templates/home.html21
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 %}
bgstack15