Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple values of drop-down list with select2 #21

Open
ananas3 opened this issue May 4, 2023 · 1 comment
Open

Multiple values of drop-down list with select2 #21

ananas3 opened this issue May 4, 2023 · 1 comment

Comments

@ananas3
Copy link

ananas3 commented May 4, 2023

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));
@ananas3 ananas3 changed the title Multiple values of with select2 Multiple values of drop-down lis with select2 May 4, 2023
@ananas3 ananas3 changed the title Multiple values of drop-down lis with select2 Multiple values of drop-down list with select2 May 4, 2023
@ishikawa999
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants