2016-09-07 16 views
-2

私は現在のドロップダウンリスト(mvcによって足場を張る)を検索可能にしようとしています。mvc5で検索可能なドロップダウンリストを作成する方法は?

このスクリプトを追加しましたが、役に立たなかった。

<script type="text/javascript"> 
$(document).ready(function() { 
     $("select").searchable({ 
      maxListSize: 100, 
      maxMultiMatch: 50, 
      exactMatch: false, 
      wildcards: true, 
      ignoreCase: true, 
      latency: 200, 
      warnMultiMatch: 'top {0} matches ...', 
      warnNoMatch: 'no matches ...', 
      zIndex: 'auto' 
     }); 
}); 

これらは私のドロップダウンリスト

<div class="form-group"> 
     @Html.LabelFor(model => model.CustomerID, "CustomerID", htmlAttributes: new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      @Html.DropDownList("CustomerID", null, htmlAttributes: new {@class = "form-control" }) 
      @Html.ValidationMessageFor(model => model.CustomerID, "", new { @class = "text-danger" }) 
     </div> 
    </div> 

    <div class="form-group"> 
     @Html.LabelFor(model => model.VideoID, "VideoID", htmlAttributes: new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      @Html.DropDownList("VideoID", null, htmlAttributes: new { @class = "form-control" }) 
      @Html.ValidationMessageFor(model => model.VideoID, "", new { @class = "text-danger" }) 
     </div> 
    </div> 

答えて

0
<div class="form-group"> 
     @Html.LabelFor(model => model.VideoID, "VideoID", htmlAttributes: new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      @Html.DropDownList("VideoID", null, htmlAttributes: new { @class = "form-control",@class="select2" }) 
      @Html.ValidationMessageFor(model => model.VideoID, "", new { @class = "text-danger" }) 
     </div> 
    </div> 

<script type="text/javascript"> 
    $(document).ready(function() { 
     $(".select2").select2(); 
    }); 
    </script> 

<select class="js-example-basic-single"> 
    <option value="AL">Alabama</option> 
    ... 
    <option value="WY">Wyoming</option> 
</select> 
です
関連する問題