diff --git a/view/js/main.js b/view/js/main.js index 3370d7ccd3..cd09de0143 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 5796bb735c..31b9287ba8 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 947ae974e8..75983b36ee 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 620d2de75a..18a6105a6e 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}}