src/hdalab/static/hdalab/js/manage.js
changeset 473 f469ab22542d
child 474 7ec378cc1f8a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hdalab/static/hdalab/js/manage.js	Wed Mar 04 15:24:23 2015 +0100
@@ -0,0 +1,17 @@
+"use strict";
+
+$(document).ready(function() {
+
+    $(".favorite-checkbox").click(function(e) {
+        var chkbox = $(e.target);
+        var form = $(e.target).parents('form')[0];
+        $.post($(form).attr('action'), $(form).serialize(), function(data) {
+            if(chkbox.prop('checked') !== data.renkan.favorite) {
+                chkbox.prop('checked', data.renkan.favorite);
+            }
+        }).fail(function() {
+            chkbox.prop('checked', !chkbox.prop('checked'));
+        });
+        
+    });
+});