Ajax Load ClistView

Hi All

I have a ajaxLink that opens a zii.widgets.jui.CJuiDialog.

This is a form that adds data to a database.

The form is submitted by a ajaxSubmitButton.

On the same page as the ajaxLink I have a view that has a zii.widgets.CListView to display the data from the database.

How do I get the zii.widgets.CListView to refresh the data when I submit the form from the zii.widgets.jui.CJuiDialog ajaxSubmitButton call.

view.php




    <?php 

        echo CHtml::ajaxLink(Yii::t('test','<span>+</span> Add'),$this->createUrl('text/create', array('id'=>$model->id)),array(

            'onclick'=>'$("#testDialog").dialog("open"); return false;',

            'update'=>'#testDialog'

        ),array('id'=>'testCreateDialog'));

  

    ?>  

        <div id="testDialog" style="display: none"></div>


<?php 


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

    'dataProvider'=>$dataProviderDoc,

    'itemView'=>'_testdoc',

    'template'=>'{items}<div class="p-pager">{pager}</div>',

    'afterAjaxUpdate'=>$itemClick,

    'id'=>'test', 

    'pager' => array (

        'class' => 'CustomLinkPager', 

        'cssFile' => false,

        'maxButtonCount' => 0,

    ),  

)); 



_testdoc.php





        <?php  

            echo CHtml::ajaxSubmitButton(Yii::t('test','Create'),CHtml::normalizeUrl(array('test/create','render'=>false)),array(

                'dataType'=>'json',

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

                        if (data.result == "error") {

                            $(".errorSummary").html(data.msg);

                            $(".errorSummary").show();

                        }

                        if (data.result == "success") {

 

                            $("#testDialog").empty();

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

                        }

                }',

    

                ),array('id'=>'closeTestDialog')); 

?>



Regards

On your ajaxSubmitButton you can add ‘complete’ to call an Ajax function to refresh your CListView:




'complete' => 'js:function(){refreshList()}'



You will need a new method in your controller for the Ajax action and a view file to display only the list.