Answers for "kartik select2 ajax"

0

kartik select2 ajax

echo $form->field($model, 'city')->widget(Select2::classname(), [
    'data' => $data,
    'options' => ['multiple'=>true, 'placeholder' => 'Search for a city ...'],
    'pluginOptions' => [
        'allowClear' => true,
        'minimumInputLength' => 3,
        'language' => [
            'errorLoading' => new JsExpression("function () { return 'Waiting for results...'; }"),
        ],
        'ajax' => [
            'url' => $url,
            'dataType' => 'json',
            'data' => new JsExpression('function(params) { return {q:params.term}; }')
        ],
        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
        'templateResult' => new JsExpression('function(city) { return city.text; }'),
        'templateSelection' => new JsExpression('function (city) { return city.text; }'),
    ],
]);
Posted by: Guest on September-14-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language