Problem with CJuiDialog, AJAX and $processOutput

Hi,

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")

                        return;


                if(isset($this->_coreScripts[$name]))

			return;



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: http://www.yiiframework.com/forum/index.php?/topic/1710-ajaxsubmitbutton-works-only-once/

Yii version: 1.1rc

Any other ideas or should I open a ticket?

Best regards,

schmunk

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 http://code.google.com/p/yii/issues/detail?id=38

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 ;)