From b3b3300bd61d9d5b5812652ce47f50a50dc7e814 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 13 Jan 2015 00:25:44 -0500 Subject: [PATCH] fixing bug with checkboxes, #2588 --- public/src/client/groups/details.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index d4effed12d..62371368e8 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -96,19 +96,18 @@ define('forum/groups/details', ['iconSelect', 'vendor/colorpicker/colorpicker', }; Details.update = function() { - var settingsFormEl = $('.groups form'); + var settingsFormEl = $('.groups form'), + checkboxes = settingsFormEl.find('input[type="checkbox"][name]'); if (settingsFormEl.length) { require(['vendor/jquery/serializeObject/jquery.ba-serializeobject.min'], function() { - var settings = settingsFormEl.serializeObject(), - keys = Object.keys(settings), - inputEl; + var settings = settingsFormEl.serializeObject(); // Fix checkbox values - keys.forEach(function(key) { - inputEl = settingsFormEl.find('input[type="checkbox"][name="' + key + '"]'); + checkboxes.each(function(idx, inputEl) { + inputEl = $(inputEl); if (inputEl.length) { - settings[key] = settings[key] === 'on' ? true : false; + settings[inputEl.attr('name')] = inputEl.prop('checked'); } }); @@ -126,7 +125,7 @@ define('forum/groups/details', ['iconSelect', 'vendor/colorpicker/colorpicker', ajaxify.refresh(); } - app.alertSuccess('[[groups:event.updated'); + app.alertSuccess('[[groups:event.updated]]'); }); }); } @@ -153,6 +152,8 @@ define('forum/groups/details', ['iconSelect', 'vendor/colorpicker/colorpicker', }); }; + // Cover Photo Handling Code + Details.initialiseCover = function() { var coverEl = $('.group-cover'); coverEl.find('.change').on('click', function() { @@ -165,11 +166,9 @@ define('forum/groups/details', ['iconSelect', 'vendor/colorpicker/colorpicker', }); coverEl.find('.save').on('click', Details.cover.save); - coverEl.addClass('initialised') + coverEl.addClass('initialised'); }; - // Cover Photo Handling Code - Details.cover.load = function() { socket.emit('groups.cover.get', { groupName: ajaxify.variables.get('group_name')