diff --git a/view/js/main.js b/view/js/main.js
index 3370d7ccd..cd09de014 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -793,11 +793,25 @@ function profChangeMember(gid,cid) {
});
}
-function contactgroupChangeMember(gid,cid) {
+function contactgroupChangeMember(checkbox, gid, cid) {
+ let url;
+ // checkbox.checked is the checkbox state after the click
+ if (checkbox.checked) {
+ url = 'group/' + gid + '/add/' + cid;
+ } else {
+ url = 'group/' + gid + '/remove/' + cid;
+ }
$('body').css('cursor', 'wait');
- $.get('contactgroup/' + gid + '/' + cid, function(data) {
- $('body').css('cursor', 'auto');
+ $.post(url)
+ .error(function () {
+ // Restores previous state in case of error
+ checkbox.checked = !checkbox.checked;
+ })
+ .always(function() {
+ $('body').css('cursor', 'auto');
});
+
+ return true;
}
function checkboxhighlight(box) {
diff --git a/view/templates/group_side.tpl b/view/templates/group_side.tpl
index 5796bb735..31b9287ba 100644
--- a/view/templates/group_side.tpl
+++ b/view/templates/group_side.tpl
@@ -9,7 +9,7 @@
{{if $group.cid}}
{{/if}}
diff --git a/view/theme/frio/templates/group_side.tpl b/view/theme/frio/templates/group_side.tpl
index 947ae974e..75983b36e 100644
--- a/view/theme/frio/templates/group_side.tpl
+++ b/view/theme/frio/templates/group_side.tpl
@@ -28,7 +28,7 @@
diff --git a/view/theme/quattro/templates/group_side.tpl b/view/theme/quattro/templates/group_side.tpl
index 620d2de75..18a6105a6 100644
--- a/view/theme/quattro/templates/group_side.tpl
+++ b/view/theme/quattro/templates/group_side.tpl
@@ -17,7 +17,7 @@
{{if $group.cid}}
{{/if}}