Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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 Yii菜单链接选项不适用于ajax_Php_Jquery_Ajax_Yii - Fatal编程技术网

Php Yii菜单链接选项不适用于ajax

Php Yii菜单链接选项不适用于ajax,php,jquery,ajax,yii,Php,Jquery,Ajax,Yii,我试图在CJUI对话框中显示CGridView,但遇到了一些问题。 在我看来,我创建了一个菜单项,如下所示: $this->menu = array( array('label' => Yii::t('app', 'Afficher les participants ayant fourni cette information'), 'url' => array('Participant/ShowParticipantInfo', 'id' =>

我试图在CJUI对话框中显示CGridView,但遇到了一些问题。 在我看来,我创建了一个菜单项,如下所示:

$this->menu = array(
    array('label' => Yii::t('app', 'Afficher les participants ayant fourni cette information'), 
        'url' => array('Participant/ShowParticipantInfo', 'id' => $model->id_info),
        'linkOptions' => array(
            //'onclick' => "{viewP(); $('#dialogViewP').dialog('open'); return false}",
            'ajax' => array(
                'type' => 'POST',
                'url' =>"js:$(this).attr('href')", //array('Participant/ShowParticipantInfo', 'id' => $model->id_info),
                'update' => '#divForForm2',
            ),
        ),
);
然后我创建了一个对话框:

<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
        'id' => 'dialogViewP',
        'options' => array(
            'title' => 'Liste des participants ayant fourni cette information',
            'autoOpen' => false,
            'modal' => true,
            'width' => 500,
            'height' => 300,
        ),
     ));
    ?>
    <div id="divForForm2"></div>
    <?php $this->endWidget('dialogViewP'); ?>

但是点击菜单项,会显示任何对话框。我不知道为什么。有人能帮我吗?

我认为菜单项中不应该同时有“url”和“linkOption”属性。任何一个。 通过web开发工具,您需要在单击菜单项时检查是否有ajax XHR

如果你想实现ajax手动操作,我推荐你

即使您启动ajax请求,响应也无法激活隐藏对话框,因为如果成功,您只更新某些div divForForm2,但对话框窗口仍然关闭:“autoOpen”=>false。我建议在ajax成功后加入打开对话框

 'ajax' => array(
       'type' => 'POST',
       'url' => array('Participant/ShowParticipantInfo', 'id' => $model->id_info),
       'success' =>'js:{function(data){$("#divForForm2").html(data); $("#dialogViewP").dialog("open");}' 
        ),
 'ajax' => array(
       'type' => 'POST',
       'url' => array('Participant/ShowParticipantInfo', 'id' => $model->id_info),
       'success' =>'js:{function(data){$("#divForForm2").html(data); $("#dialogViewP").dialog("open");}' 
        ),