Problem with CJuiDialog, AJAX and $processOutput


I ran into a problem with jQuery and AJAX requests.

I have a page (with CJuiDiaglog) where jquery.js is already loaded and then I trigger a XMLHTTP-Request.

Within the content to be loaded (with an ajaxButton) ‘jquery.js’ is also automatically inserted, because I render a view with $processOutput = true.

This breaks the buttons of my CJuiDialog, they do not work anymore, FireBug says dialog() is undefined.

Because jquery is initialized a second time some event handlers are lost.

I hot-fixed this by adding these lines to CClientScript, line 352:

	public function registerCoreScript($name)


                if (Yii::app()->request->isAjaxRequest && $name == "jquery")




If this is an ajaxRequest we should be able to safely skip loading of jquery, which caused the ajaxRequest B)

Looks like this is related:

Yii version: 1.1rc

Any other ideas or should I open a ticket?

Best regards,


Yes, this is a long outstanding issue (IMHO;). There is a work-around:

Yii::app()->clientScript->scriptMap['jquery.js'] = false;

See some discussion about it here

By the way, make sure you set manually the ID and name of your Ajax button, if not, it will generate something like ‘yt0’, and that’s probably already used earlier. see this too.

Thanks Maxximus.

I’ll try your solution, looks more yii-style ;)