We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My current code is like this:
<?=$form->field($model,'customer_id')->widget(Select2::classname(), [ 'data' => ArrayHelper::map($customer,'id','customer_name'), 'theme' => 'bootstrap', 'options' => [ 'placeholder' => Yii::t('app','Select customer...'), ], 'pluginOptions' => [ 'allowClear' => true ], ])->label(Yii::t('app','Customer'));?>
As you can see allowClear is set true, but when I try to clear my selection a javascript error is trigger:
TypeError: $el.data(...) is undefined
And refer to line 91
initS2Unselect = function () { var $el = $(this), opts = $el.data('select2').options; opts.set('disabled', true); setTimeout(function() { opts.set('disabled', false); $el.trigger('krajeeselect2:cleared'); }, 1); };
Another to add to this post, is that this form is an ajax call:
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered:
I have the same issue, however it is Cannot read property 'id' of undefined instead.
Cannot read property 'id' of undefined
I am using it as a filter with the gridview:
[ 'attribute' => 'repairer.name', 'label' => 'Repairer', 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => [ 'pluginOptions' => [ 'allowClear' => true, 'ajax' => [ 'url' => Url::to(['/contact/list', 'mode' => 'repairer']), 'dataType' => 'json', 'delay'=> 10, 'data' => new JsExpression('function(params) { return { q: params.term, page: params.page}; }'), 'cache' => true ] ] ] ],
My solution was to add a placeholder. This seems to have fixed it:
'options' => ['placeholder' => ''],
Sorry, something went wrong.
No branches or pull requests
My current code is like this:
<?=$form->field($model,'customer_id')->widget(Select2::classname(), [ 'data' => ArrayHelper::map($customer,'id','customer_name'), 'theme' => 'bootstrap', 'options' => [ 'placeholder' => Yii::t('app','Select customer...'), ], 'pluginOptions' => [ 'allowClear' => true ], ])->label(Yii::t('app','Customer'));?>
As you can see allowClear is set true, but when I try to clear my selection a javascript error is trigger:
TypeError: $el.data(...) is undefined
And refer to line 91
initS2Unselect = function () { var $el = $(this), opts = $el.data('select2').options; opts.set('disabled', true); setTimeout(function() { opts.set('disabled', false); $el.trigger('krajeeselect2:cleared'); }, 1); };
Another to add to this post, is that this form is an ajax call:
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: