【发布时间】:2017-06-11 08:13:54
【问题描述】:
我使用http://demos.krajee.com/widget-details/select2#usage-tags 控制器
public function actionTagsForm()
{
$method = Yii::$app->request->isAjax ? 'renderAjax' : 'render';
$model = new UserTagsForm();
return $this->$method('tagsForm', ['model' => $model]);
}
views/layouts/main.php 有代码模式窗口
<?php
yii\bootstrap\Modal::begin([
'header' => '<div id="modalHeader"></div>',
'id' => 'modal',
'size' => 'modal-lg',
'options' => [
'tabindex' => false
],
]);
echo "<div id='modalContent'></div>";
yii\bootstrap\Modal::end();
?>
查看
$data = [
"red" => "red",
"green" => "green",
"blue" => "blue",
"orange" => "orange",
"white" => "white",
"black" => "black",
"purple" => "purple",
"cyan" => "cyan",
"teal" => "teal"
]; ?>
<div class="image-tags-index">
<?php $form = ActiveForm::begin();?>
<?php echo $form->field($model, 'image_tags')->widget( Select2::classname(),[
'data' => $data,
'options' => ['placeholder' => 'Select a state ...'],
'pluginOptions' => [
'allowClear' => true
],
])->label('Tag Multiple');
?>
</div>
错误
VM314:2 Uncaught ReferenceError: select2_3f25e3ac is not defined 在 eval (在 globalEval 的 eval (jquery.js:343), :2:56) 在评估() 在 Function.globalEval (jquery.js:343) 在 domManip (jquery.js:5291) 在 jQuery.fn.init.append (jquery.js:5431) 在 jQuery.fn.init。 (jquery.js:5525) 访问时 (jquery.js:3614) 在 jQuery.fn.init.html (jquery.js:5492) 在对象。 (jquery.js:9436) 着火了 (jquery.js:3187)
【问题讨论】:
标签: yii2 jquery-select2 kartik-v