CJuiDialog and AjaxSubmitButton

I read this cook http://www.yiiframework.com/doc/cookbook/72/ and I have a problem.

  1. Don’t work open dialog onclick link, I write other link to test this example, like this:

    echo CHtml::link('openDialog', '#', array('onclick'=>'$("#paymentDialog").dialog("open"); return false;',));

  1. My link “refresh CGridView” after open dialog don’t work (before, it’s work):

    echo CHtml::Link('Refresh', '#', array('onclick'=>'$("#payment-grid").yiiGridView.update("payment-grid"); return false;',));


Uncaught TypeError: Cannot call method 'update' of undefined

I think this is because of the use renderPartial with option $processOutput = true. What can I do? Or that I did the right thing?

Sorry my bad English

There is a lot of people pushing this out, let’s we share them our points

this is the similiar case what you want to:

How to add ajaxButton in the CGridView

How to call cjuidialog in cgridview?

for now i am using div popup and embeded it in value attribut of cgridview.

beware of other feature such a sorting, ajax search or paging when you embed some new js/ajax in cgridview since there is a lots of feature already embeded in it and mixed them all…

Thanks, I read these topic. I want ‘How to call cjuidialog in cgridview’ later, now my task to create cjuidialog near cgridview, and update grid after commit ajax form in dialog. I’ve got to update grid view after submit ajaxbutton next way: in createDialog i put tag <head> <body>





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


	// additional javascript options for the dialog plugin


		'title'=>'Create Payment',















This is help my browser to find $.fn.yiiGridView. in page,

next, I modify ajaxbutton in _formDialog view:

<?php echo CHtml::ajaxSubmitButton($model->isNewRecord ? 'Create' : 'Save',CHtml::normalizeUrl(array('payment/create','render'=>false)),array('success'=>'js: function(data) {



		}'),array('id'=>'closePaymentDialog')); ?>

Next step I want to dialogue opened with the one button. After that I will do a ajax form in dialog for update data in gridview

Still strugling with this problem.

Calling the CJuiDialog from an ajaxlink (in cgridview) has worked. However, when the dialog contains a form and the data is updated, I would like to refresh, repaint, update the gridview.

So far, it hasn’t worked, because there’s a javascript error “yiiGridView is undefined”.

How do you "define" yiiGridView in the CJuiDialog?

I have the same problem… after an ajax submit from the dialog i would to update the gridview in my main view but I get this javascript error:

[font="Courier New"]$.fn.yiiGridView is undefined[/font].

Here the code of submit button inside the dialog:

 echo CHtml::ajaxSubmitButton($label, Yii::app()->createUrl($url,array('id'=>$model->Id)),

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





Any comment is really appreciated, thanks!

Sorry, but I gave up this option, but I seem to be turned to avoid the mistake. It solved one or few of these options:

  1. use in view


</ Head>


</ Body>

  1. use renderPartial (…,…, false, true)

  2. stupid version: add load script "yiiGridView.js" in view

Hi Paha,

I tried all the solutions but none seem to work … :blink:

Hi everyone,

I’m new to Yii and this is my first post in this forum …

and I must say Yii is amazing.

I am struggling with this exact issue and am wondering if there is any known solution?

Or should I try to solve this some other way?



Hi Dude,

apparently this is a well known problem, you can read what the boss says about:

Look at the html code of your ajax response. The problem is that jquery (or maybe another core script that you already have in the page) is loaded again <_<

You can solve including this holy snippet in the partial view:


         //scripts that you don't need inside this view



Hope this help.


Thank you a lot psikocrisis!! You made my day :D


Same here! Just spent a whole day trying to figure this one out, this is gold!

Thanx alot!

Another possible solution:

Make sure that jQuery Javascript file is referenced/loaded before your <title> tag in the <head> section.

Yii used to put js scripts just before <title> so if you have this tag at the beginning of the <head> section, likely will be trying to load yii stuff before jquery.