Select2 with multiple attribute is not working with modal

☆樱花仙子☆ 提交于 2019-12-23 05:02:41

问题


I am using TbSelect2 to allow users to choose multiple data and it works fine then. But when I tried to use it with modal, it doesn't work. Does anyone have an idea? Thanks in advance.

Edit:

view.php

<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'advanceModal')); ?>

    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>
        <h4>User</h4>
    </div>

    <div class ="modal-body" id="newmodal">

    </div>

    <div class="modal-footer">

        <?php
        $this->widget('bootstrap.widgets.TbButton', array(
            'label' => 'Close',
            'url' => '#',
            'htmlOptions' => array('data-dismiss' => 'modal'),
        ));
        ?>
    </div>          

    <?php $this->endWidget(); ?>

<?php //code displaying a grid view here?>



<script>
//ajax call to go to the modal
</script>

modal.php

<?php

//table

//code of select2
$this->widget('bootstrap.widgets.TbSelect2',array(
                    'model'=>$model,                
                    'attribute'=>'name',
                    'data'=>CHtml::listData(User::model()->findAll(), 'id', 'label'),
                    'options'=>array(
                                'width'=>'200px',
                                'placeholder'=>' -- Please select trait-- ', // add this line
                                'allowClear'=>true,
                        ),
                    'htmlOptions'=>array('multiple'=>'multiple',),
                    ));

?>

来源:https://stackoverflow.com/questions/18691230/select2-with-multiple-attribute-is-not-working-with-modal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!