redmine_searchable_selectbox
redmine_searchable_selectbox copied to clipboard
Multiple values of drop-down list with select2
This is not a Pull request, but just an optional suggestion. Depending on the number of options, we may use different types of List field. For example, if the number of options is less than 10 or so, use a checkbox, if more, use a drop-down list. If the List field is a drop-down list with multiple options, I believe select2 is more convenient. So I tried to modify the local source code as following.
diff --git a/assets/javascripts/searchable_selectbox.js b/assets/javascripts/searchable_selectbox.js
index dedb790..50324b7 100644
--- a/assets/javascripts/searchable_selectbox.js
+++ b/assets/javascripts/searchable_selectbox.js
@@ -70,7 +70,7 @@ function replaceSelect2() {
if ($('body').hasClass('controller-workflows')) {
return;
} else {
- var selectInTabular = $('.tabular .splitcontent select:not([multiple]):not([data-remote]):not(.select2-hidden-accessible)');
+ var selectInTabular = $('.tabular .splitcontent select:not([check_box_group]):not([data-remote]):not(.select2-hidden-accessible)');
if (selectInTabular.length) {
selectInTabular.select2({
width: 'style'
@@ -79,7 +79,7 @@ function replaceSelect2() {
});
}
- var other = $('select:not([multiple]):not([data-remote]):not(.select2-hidden-accessible)');
+ var other = $('select:not([check_box_group]):not([data-remote]):not(.select2-hidden-accessible)');
if (other.length) {
other.select2().on('select2:select', function() {
retriggerChangeIfNativeEventExists($(this));
Thank you for the good ideas. If there are more than 10 choices in the List field, it might be more convenient to apply select2.
I have not realised the need for this as my Redmine does not have a List field with many choices. Thanks.