當您使用select2'多選框'選項時,它提供了輸入文本的選項。我想刪除此功能,以便用戶只能點擊/觸摸可用選項,並且文本光標不會顯示。如何在無法輸入文字的情況下在Select2中使用'多個選擇框'選項?
你可以看到他們的榜樣頁上的「多選擇框」選項:https://select2.github.io/examples.html
我的代碼。 (我使用Laravel 5刀模板)
<div class="row searchBoxes show">
{!! Form::open(['method' => 'GET', 'id' => 'searchForm', 'name' => 'searchForm', 'route' => 'articles_path']) !!}
{!! Form::select('categoryList[]', $categories, null, ['class' => 'categorySelector', 'id' => 'categoryList', 'multiple']) !!}
{!! Form::select('dayList[]', $days, null, ['class' => 'distanceSelector', 'id' => 'dayList', 'multiple']) !!}
{!! Form::submit('MAKE ME HAPPY', array('id' => 'submitButton', 'class' => 'searchSubmit')) !!}
{!! Form::close() !!}
</div>
<script type="text/javascript">
$('#categoryList').select2({
placeholder: "CATEGORY",
minimumResultsForSearch: -1
});
$('#dayList').select2({
placeholder: "DAY",
minimumResultsForSearch: -1
});
</script>
編輯: 我發現了大約'Hiding the search box'的信息。我試圖將minimumResultsForSearch切換到'無限',但它仍然無法工作。這是我的應用程序:www.gethappy.co.nz
謝謝,這不適合我?我在我的選擇下拉列表中有4個選項。嘗試將minimumResultsForSearch更改爲10。沒有工作。有任何想法嗎? –
你能發佈html嗎?這將有助於找出問題。 – DinoMyte
增加了更多的代碼。目前它工作正常,但無法擺脫文本輸入。 –