mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Fix for unchecked-checkbox value submission.
This commit is contained in:
36
e107_web/js/bootstrap.switch.init.js
vendored
36
e107_web/js/bootstrap.switch.init.js
vendored
@@ -18,12 +18,36 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
{
|
||||
$('input[name="' + name + '"]', context).once('bootstrap-switch-init').each(function ()
|
||||
{
|
||||
$(this).bootstrapSwitch({
|
||||
size: options.size || 'mini',
|
||||
onText: options.onText || null,
|
||||
offText: options.offText || null,
|
||||
wrapperClass: options.wrapperClass || null
|
||||
});
|
||||
if($(this).attr('type') != 'hidden')
|
||||
{
|
||||
$(this).bootstrapSwitch({
|
||||
size: options.size || 'mini',
|
||||
onText: options.onText || null,
|
||||
offText: options.offText || null,
|
||||
wrapperClass: options.wrapperClass || null
|
||||
});
|
||||
|
||||
$(this).on('switchChange.bootstrapSwitch', function (event, state) {
|
||||
var name = $(this).attr('name');
|
||||
var checked = true;
|
||||
|
||||
if(state === false)
|
||||
{
|
||||
checked = false;
|
||||
}
|
||||
|
||||
var value = checked ? 1 : 0;
|
||||
|
||||
if(options.inverse)
|
||||
{
|
||||
// value = checked ? 0 : 1;
|
||||
}
|
||||
|
||||
$('input[type="hidden"][name="' + name + '"]').val(value);
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user