CJuiDIalog and CGridView with ajaxLink

in my merides/create view i have this ajaxLink and an empty <div>


<?php echo CHtml::ajaxLink('Find', $this->createUrl('/person/persongrid',

array('inputField'=>'Merides_senderid')),

array('update'=>'#dialog_ground'),

array('id'=>'senderDialog')); ?> 

<div id="dialog_ground" ></div>

which calls this action.




        public function actionPersongrid() {                                                                                                                 

                $model=new Person('search');                                                                                                                 

                if( isset($_GET['inputField']) ){                                                                                                            

                    $inputField=$_GET['inputField'];                                                                                                         

                }                                                                                                                                            

                if(isset($_GET['Person'])) {                                                                                                                 

                        $attributes = $_GET['Person'];                                                                                                       

                        if( isset( $attributes['myf'] ) ) {                                                                                                  

                            $myf = PersonMyf::model()->findByAttributes(array('myf'=>$attributes['myf']));                                                   

                            if( !empty($myf) )                                                                                                               

                                $attributes['myf'] = $myf->id;                                                                                               

                        }                                                                                                                                    

                        $model->attributes=$attributes; }                                                                                                    

                $this->renderPartial('persongridview',array(                                                                                                 

                        'model'=>$model,                                                                                                                     

                        'inputField'=>$inputField,                                                                                                           

                ),false,true);                                                                                                                               

        } 

Where the persongridview it is called is this.


<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(

    'id'=>'personsdialog',

    // additional javascript options for the dialog plugin

    'options'=>array(

        'title'=>'Person dialog',

        'autoOpen'=>true,

        'modal'=>false,

        'width'=>'auto',

    ))

);

      $dp = $model->search();

      $dp->keyAttribute='personid';

      $this->widget('zii.widgets.grid.CGridView', array(

        'id'=>'person-grid',

        'dataProvider'=>$dp,

        'filter'=>$model,

        'columns'=>array(

                array(

                  'name'=>'personid',

                  'value'=>'$data->personid',

                  //'visible'=>false,

                ),

                'personid',

                'fullname',

                'afm',

                'vat',

                array(

                    'name'=>'myf',

                    'value'=>'$data->fk_myf->myf',

                )

                /*

                'type',

                'indate',

                'saler',

                'email',

                'customerlgl',

                'supplierlgl',

                'jid',

                */

        ),

));?>

<div class="row button" align="right">

<?php echo CHtml::ajaxButton('Select','',

        array('success'=>'js:function() {

            var p_sel = $.fn.yiiGridView.getSelection("person-grid");

            if ( p_sel != "") {

                $("#personsdialog").dialog("close");

                $("#'.$inputField.'").val(p_sel);

            }

        }'),array('id'=>'selectButton'));

      

?>

</div>

<?php $this->endWidget('zii.widgets.jui.CJuiDialog');



The issue i am facing is this…Image

Check where is the pointer…The return of the CJuiDialog are not in the div as i set to update but outside of it…this will have conflicts when i will try to get a CJuiDialog for a second time …etc

tydeas_dr, this is a problem I faced too and I guess many yii developers too.

Summarizing the question is:

calling


 $this->renderPartial('view',array(),false,true);  

create conflicts with all clientScript that are OUTSIDE the div to update and the call of


 $this->renderPartial('view',array());  

doesn’t render the clientScript INSIDE the div.

I have no solution for this problem.

In my opinion, the framework should provide the possibility of create an own ClientScriptManager for collect the client script of the div to change with ajax.

This ClientScriptManager should be rendered inside the div so that will no modify the "main" client script.

I have no idea of how to do (and if is possible).

Should i repo this to code.google.com repo?

Well, I am not 100% sure that is a mistake.

Maybe you can open a thread in bug report explainig what is our problem. If is a mistake the staff will advice us to create a ticket.

Moved topic to bug reports. Can’t say anything about the issue itself.

Google code repository issue report for this.

Take a look at this post