Cmultifileupload Not Reinitialising Whith Ajax And Renderpartial


I have a popup window loaded by ajax with renderPartial in my controller:

$return['html'] = $this->renderPartial('//user/messages/ticket/create',array(


        ), true, false);

and it renders a file upload field using CMultiFileUpload, agian, with renderPartial, so that all the added javascript is in the <div> I append to the site (this is not the whole file):


    $this->renderPartial('//user/messages/ticket/_attachment', array(), false, true);


The contents of this file are (this is the whole file):


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

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

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

$this->widget('CMultiFileUpload', array(

    'name' => 'attachments',



    'accept' => 'jpeg|jpg|gif|png', // useful for verifying files

    'duplicate' => 'Duplicate file!', // useful, i think

    'denied' => 'Invalid file type', // useful, i think

    'options' => array(

        'onFileAppend'=>'function(e, v, m){ addReplyHeight() }',

        'onFileRemove'=>'function(e, v, m){ removeReplyHeight() }',




This code ($return[‘html’]) then is sent to an ajax function, that renders it. After user adds the files and submits it, this popup is closed and the code is removed.

The problem is, that when user opens this popup again, the CMultiFileUpload plugin breaks and JS console in Chrome returns: Uncaught TypeError: Cannot read property ‘apply’ of undefined

If I remove

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

it works, but all other jquery breaks.

Has anyone encountered something similar?

Is there a way to fix this, or do I need to change the way I render it altogether?

Hi,please try with renderpartial with parameter true,false… lets keep on trying…