Speaktech.in

Yii2 Kartik Select2 widget how to make an ajax call on select event

Yii2 Kartik Select2 widget how to make an ajax call on select event?


You can use select2:select event to make ajax call.

echo $form->field($model,'state_1')->widget(Select2::classname(),['data'=> $data,'options'=>['placeholder'=>'Select a state ...'],'pluginOptions'=>['allowClear'=>true],'pluginEvents'=>["select2:select"=>"function() { // function to make ajax call here }",]]);