I am using kartik select2 library. I have the modal which is loading in the page from ajax with renderAjax. The modal has the select2 dropdown.
The problem is it load the js but do not load the css files of select2.
echo $form->field($assign_model, 'applicant_id')->widget(Select2::classname(), [
'data' => $applicant,
'attribute' => 'applicant_id',
'options' => ['placeholder' => 'Select an applicant', 'multiple' => 'multiple', 'style' => "width:100%"],
'pluginEvents' => [
"select2:selecting" => "function() { "
. "no_position = $('body').data('no_position');"
. "if(no_position>= " . $model->no_of_persons . "){alert('You can select only " . $model->no_of_persons . " applicant(s)');return false;} }",
"select2:select" => "function() { "
. "no_position = $('body').data('no_position');"
. "$('body').data('no_position',++no_position);}",
"select2:unselect" => "function() { "
. "no_position = $('body').data('no_position');"
. "$('body').data('no_position',--no_position);}",
],
'pluginOptions' => [
'allowClear' => true,
]
]);