Answer the question
In order to leave comments, you need to log in
How to make Select2 expand on all keys except Enter?
I use this widget for Yii2 to use Select2.
echo \kartik\select2\Select2::widget([
'name' => 'details',
'value' => '',
'readonly' => true,
'pluginLoading' => false,
'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP,
'data' => \yii\helpers\ArrayHelper::map(\app\models\DetailNames::find()->orderBy("Name")->all(), 'id', 'Name'),
'options' => ['placeholder' => 'Деталь'],
'pluginOptions' => [
'allowClear' => true
],
'pluginEvents' => [
"select2:select" => "function(data) { searchParts.idDetail = data.params.data.id; }",
"select2:unselect" => "function() { searchParts.idDetail = false; }",
],
]);
<select id="w0" class="form-control select2-hidden-accessible" name="details" readonly="" data-s2-options="s2options_6cc131ae" data-krajee-select2="select2_c2410efe" tabindex="-1" aria-hidden="true">
<option value="">Деталь</option>
<option value="">Деталь1</option>
<option value="">Деталь2</option>
<option value="">Деталь3</option>
</select>
<span class="select2 select2-container select2-container--bootstrap select2-container--below select2-container--focus" dir="ltr" style="width: 100%;"><span class="selection"><span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-w0-container"><span class="select2-selection__rendered" id="select2-w0-container"><span class="select2-selection__placeholder">Деталь</span></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question