fixing bug with checkboxes, #2588

v1.18.x
Julian Lam 10 years ago
parent de58f4ff6b
commit b3b3300bd6

@ -96,19 +96,18 @@ define('forum/groups/details', ['iconSelect', 'vendor/colorpicker/colorpicker',
}; };
Details.update = function() { Details.update = function() {
var settingsFormEl = $('.groups form'); var settingsFormEl = $('.groups form'),
checkboxes = settingsFormEl.find('input[type="checkbox"][name]');
if (settingsFormEl.length) { if (settingsFormEl.length) {
require(['vendor/jquery/serializeObject/jquery.ba-serializeobject.min'], function() { require(['vendor/jquery/serializeObject/jquery.ba-serializeobject.min'], function() {
var settings = settingsFormEl.serializeObject(), var settings = settingsFormEl.serializeObject();
keys = Object.keys(settings),
inputEl;
// Fix checkbox values // Fix checkbox values
keys.forEach(function(key) { checkboxes.each(function(idx, inputEl) {
inputEl = settingsFormEl.find('input[type="checkbox"][name="' + key + '"]'); inputEl = $(inputEl);
if (inputEl.length) { 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(); 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() { Details.initialiseCover = function() {
var coverEl = $('.group-cover'); var coverEl = $('.group-cover');
coverEl.find('.change').on('click', function() { 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.find('.save').on('click', Details.cover.save);
coverEl.addClass('initialised') coverEl.addClass('initialised');
}; };
// Cover Photo Handling Code
Details.cover.load = function() { Details.cover.load = function() {
socket.emit('groups.cover.get', { socket.emit('groups.cover.get', {
groupName: ajaxify.variables.get('group_name') groupName: ajaxify.variables.get('group_name')

Loading…
Cancel
Save