Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 具有多个属性的Select2不适用于modal_Php_Html_Yii - Fatal编程技术网

Php 具有多个属性的Select2不适用于modal

Php 具有多个属性的Select2不适用于modal,php,html,yii,Php,Html,Yii,我使用TbSelect2允许用户选择多个数据,这样就可以了。但是当我尝试将它与modal一起使用时,它不起作用。有人有主意吗?提前谢谢 编辑: view.php <?php $this->beginWidget('bootstrap.widgets.TbModal', array('id' => 'advanceModal')); ?> <div class="modal-header"> <a class="close" da

我使用TbSelect2允许用户选择多个数据,这样就可以了。但是当我尝试将它与modal一起使用时,它不起作用。有人有主意吗?提前谢谢

编辑:

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>

×
使用者
//ajax调用转到模态
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',),
                    ));

?>


您有什么可以分享的小提琴或代码吗?很抱歉反应太晚。我包括了示例代码。我希望您能帮我找出问题所在。如果您在ajax调用中使用
renderPartial()
,那么这是常见的问题。第一个可以是脚本的双重加载,在本例中,`Yii::app()->clientscript->scriptMap['*.js']=false;`我可以帮忙。第二,您需要自己在ajax success或其他地方注册select2。如何实现Yii::app()->clientscript->scriptMap['*.js']=false?(抱歉,我不熟悉)我调用我的模式的脚本如下:
$.ajax({cache:false,url:'',数据类型:'json',类型:'POST',数据:{data:selected},成功:函数(数据){$('#modal').html(数据);}})