【发布时间】:2020-06-30 09:35:11
【问题描述】:
我是一个新的Yii2。我有这个bug,我不知道如何解决这个问题。
Bug 很简单,templateSelection 调用了两次。这是我的代码。
如果我在 select2 中提交内容,则 templateSelection 会调用两次。
echo Select2::widget([
'name' => 'blogId',
'options' => ['placeholder' => 'Search for [![enter image description here][1]][1] ...'],
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 1,
'ajax' => [
'url' => Url::to(['/controller/action']),
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }'),
'processResults' => new JsExpression($resultsJs),
],
'templateResult' => new JsExpression($formatRepo),
'templateSelection' => new JsExpression('function(params) { console.log("tst");}'),
],
]);
感谢您的帮助。
【问题讨论】:
标签: php yii2 jquery-select2 kartik-v