Skip to content

Multiple values of drop-down list with select2 #21

@ananas3

Description

@ananas3

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));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions