Answer the question
In order to leave comments, you need to log in
Why doesn't my select2 event fire?
I do not have an event when clicking on the button, who can tell me what's wrong?
<?= $form->field($client, 'phone')->widget(Select2::className(), [
'data' => ArrayHelper::map(Client::find()->all(), 'id', 'phone', 'fio'),
'options' => ['placeholder' => 'Введите номер телефона'],
'pluginOptions' => [
'allowClear' => true,
'language' => [
'noResults' => new JsExpression('function () { return "<button type=\"button\" class=\"btn btn-primary btn-xs createClient\" value=\"'.\yii\helpers\Url::to(['client/create']).'\">Добавить клиента</button>"; }'),
],
'escapeMarkup' => new JsExpression('function (markup) {
return markup;
}')
],
])?>
$('.createClient').click(function(){
console.log('Нажата')
});
Answer the question
In order to leave comments, you need to log in
1. make sure that the click is on createClient. What he is and he is 1, etc.
2. try like this
$(body).on('click','.createClient',function(){
console.log('Нажата');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question