summaryrefslogtreecommitdiffstats
path: root/hyperkitty/static/js
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2012-12-10 12:25:38 +0100
committerAurélien Bompard <aurelien@bompard.org>2012-12-10 12:25:38 +0100
commit6ea042ab3c6310bb87cb01041656e6928a163a5f (patch)
treea191c3d7dbd9de77f7b24c69b31bbb9af0eadbf1 /hyperkitty/static/js
parent1efaf31a907aa42fc0b01029d332f539b2067a75 (diff)
downloadhyperkitty-6ea042ab3c6310bb87cb01041656e6928a163a5f.tar.gz
hyperkitty-6ea042ab3c6310bb87cb01041656e6928a163a5f.tar.xz
hyperkitty-6ea042ab3c6310bb87cb01041656e6928a163a5f.zip
Don't reload the page when adding tags or liking stuff
Diffstat (limited to 'hyperkitty/static/js')
-rw-r--r--hyperkitty/static/js/hyperkitty.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/hyperkitty/static/js/hyperkitty.js b/hyperkitty/static/js/hyperkitty.js
index 238954d..2b6a818 100644
--- a/hyperkitty/static/js/hyperkitty.js
+++ b/hyperkitty/static/js/hyperkitty.js
@@ -36,13 +36,15 @@ function vote(elem, value) {
$.ajax({
type: "POST",
url: $(elem).parent("form").attr("action"),
+ dataType: "json",
data: data,
success: function(response) {
- // @TODO : Remove this reload and update the count using the AJAX response
- location.reload();
+ var likestatus = $(elem).parent("form").find(".likestatus");
+ likestatus.find(".likecount").html(response.like);
+ likestatus.find(".dislikecount").html(response.dislike);
},
error: function(jqXHR, textStatus, errorThrown) {
- // You must be authenticated to do that
+ // authentication or double-vote
if (jqXHR.status === 403) {
alert(jqXHR.responseText);
}
@@ -65,17 +67,15 @@ function setup_add_tag() {
$("#add_tag_form").submit( function () {
$.ajax({
type: "POST",
+ dataType: "json",
data : $(this).serialize(),
url: $(this).attr("action"),
- success: function(data){
- // @TODO : Remove this reload and update the tag list using the AJAX response
- //location.reload();
+ success: function(data) {
+ $("#tags").html(data.html);
},
error: function(jqXHR, textStatus, errorThrown) {
- // You must be authenticated to do that
- if (jqXHR.status === 403) {
- alert(jqXHR.responseText);
- }
+ // authentication and invalid data
+ alert(jqXHR.responseText);
}
});
return false;