0

我使用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 未定义在 eval (eval at globalEval (jquery.js:343), :2:56) at eval () at Function.globalEval (jquery.js:343) at domManip (jquery.js :5291) 在 jQuery.fn.init 的 jQuery.fn.init.append (jquery.js:5431)。(jquery.js:5525) 在对象的 jQuery.fn.init.html (jquery.js:5492) 处访问 (jquery.js:3614)。(jquery.js:9436) 着火 (jquery.js:3187)

4

1 回答 1

0

这个问题已经在https://github.com/kartik-v/yii2-widget-select2/issues/211中解决了

于 2017-09-17T12:34:04.867 回答