mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
Fixed Multiselect dropdown so that an empty value also gets saved.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
* https://github.com/davidstutz/bootstrap-multiselect
|
* https://github.com/davidstutz/bootstrap-multiselect
|
||||||
*
|
*
|
||||||
* Copyright 2012 David Stutz
|
* Copyright 2012 David Stutz
|
||||||
|
* Modified Dec 2019 by e107
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@@ -565,6 +565,7 @@ $(document).ready(function()
|
|||||||
$("select.tbox").each(function() {
|
$("select.tbox").each(function() {
|
||||||
|
|
||||||
var multi = $(this).attr('multiple');
|
var multi = $(this).attr('multiple');
|
||||||
|
var tagName = $(this).attr('name');
|
||||||
|
|
||||||
if(multi === undefined)
|
if(multi === undefined)
|
||||||
{
|
{
|
||||||
@@ -573,7 +574,27 @@ $(document).ready(function()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$(this).multiselect({ buttonClass: 'btn btn-default'} );
|
$(this).multiselect({
|
||||||
|
buttonClass: 'btn btn-default',
|
||||||
|
buttonText: function(options) {
|
||||||
|
if (options.length == 0) {
|
||||||
|
|
||||||
|
return '(Optional) <b class="caret"></b><input type="hidden" name="' + tagName + '" value="" />'; // send empty value to server so value is saved.
|
||||||
|
}
|
||||||
|
else if (options.length > 5) {
|
||||||
|
return options.length + ' selected <b class="caret"></b>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var selected = '';
|
||||||
|
options.each(function() {
|
||||||
|
selected += $(this).text() + ', ';
|
||||||
|
});
|
||||||
|
return selected.substr(0, selected.length -2) + ' <b class="caret"></b>';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user