Bootstrap multi-select - 使用Group Labels过滤问题

时间:2015-08-20 06:42:57

标签: html css ruby-on-rails twitter-bootstrap

我在Rails Web应用程序中使用Bootstrap (2.3.2) multiselect。我在multlectlect中使用的功能如下所示:

<script type="text/javascript">
  $(function() { 
    $('#coder_prod_select_client').multiselect({
      includeSelectAllOption: true,
      enableCaseInsensitiveFiltering: true,
      numberDisplayed: 0,
      nonSelectedText: 'Select Facility',
      maxHeight: 450
    });
  });
</script>

以下是HTML代码:

<div id="coder_prod_facilities_for_select">
    <select name="facility[]" multiple="multiple" id="coder_prod_select_facility" style="display: none;">
        <option value="multiselect-all"> Select all</option>
        <optgroup label="Group 1">
            <option value="114">Ancillary</option>
            <option value="115">Inpatient</option>
            <option value="117">Emergency</option>
        </optgroup>
        <optgroup label="Group 2">
            <option value="80">Inpatient</option>
            <option value="81">SS Surgery</option>
            <option value="90">Emergency</option>
        </optgroup>
        <optgroup label="Group 3">
            <option value="73">Inpatient</option>
            <option value="75">Observation</option>
            <option value="76">SS Surgery</option>
            <option value="77">Ancillary</option>
        </optgroup>
    </select>

    <div class="btn-group">
        <button data-toggle="dropdown" class="multiselect dropdown-toggle btn btn-default" type="button" title="Select Facility">
            Select Facility
            <b class="caret"></b>
        </button>
        <ul class="multiselect-container dropdown-menu" style="max-height: 450px; overflow-y: auto; overflow-x: hidden;">
            <div class="input-group">
                <span class="input-group-addon">
                    <i class="glyphicon glyphicon-search"></i>
                </span>
                <input type="text" class="form-control multiselect-search" placeholder="Search">
            </div>
            <li>
                <a href="javascript:void(0);" class="multiselect-all">
                    <label class="checkbox"><input type="checkbox" value="multiselect-all">  Select all</label>
                </a>
            </li>
            <li style="display: list-item;">
                <label class="multiselect-group">Group 1</label>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="114"> Ancillary</label>
                </a>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="115"> Inpatient</label>
                </a>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="117"> Emergency</label>
                </a>
            </li>
            <li style="display: list-item;">
                <label class="multiselect-group">Group 2</label>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="80"> Inpatient</label>
                </a>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="81"> SS Surgery</label>
                </a>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="90"> Emergency</label>
                </a>
            </li>
            <li style="display: list-item;">
                <label class="multiselect-group">Group 3</label>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox">
                        <input type="checkbox" value="73"> Inpatient</label>
                </a>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="75"> Observation</label>
                </a>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="76"> SS Surgery</label>
                </a>
            </li>
            <li style="display: list-item;">
                <a href="javascript:void(0);">
                    <label class="checkbox"><input type="checkbox" value="77"> Ancillary</label>
                </a>
            </li>
        </ul>
    </div>
</div>

下面您可以看到默认的视图/ HTML。 enter image description here

您可以看到每个组下面都有类似的元素。例如,当我使用值'inpatient'进行过滤时,它会显示结果,如下面的附件所示。

enter image description here

但是,每个过滤后的“住院病人”值都属于不同的组,并且所有值都应该显示在其顶部的组名,但不是。

有人可以帮我识别并解决问题吗?

1 个答案:

答案 0 :(得分:0)

您可能想再次检查js,不应该是$("#coder_prod_select_facility").multiselect(...)