Hi,
I’m implementing an ajax file uploader (eAjaxUpload) in a modal form with a simple file list of results.
Every time a file is uploaded, the file list (based on a yiiListView) has to be updated with the brand new file link.
Everything works fine until the "onComplete" js function updates the yiiListView: the yiiListView totally disappears!
Firebug reports that the GET action (used to pass the yiiListView command) returns in its HTML response tab: {"status":"failure","content":"\n\n\n (and nothing else)
while in the Firebug’s “raw” response tab I can see the complete yiiListView’s html code updated with the new file link!
What’s going on?
this is code inside the yii form:
the uploader:
...other form tags...
$this->widget('application.extensions.EAjaxUpload.EAjaxUpload', array(
'id'=>'uploadFile',
'config'=>array(
'action'=>Yii::app()->createUrl('preventivo/ajaxUpload', Array('bes_id'=>$model->bes_richiesta_id, 'prev_id'=>$model->id)),
'allowedExtensions'=>Yii::app()->params['besExtAllowed'],
'sizeLimit'=>Yii::app()->params['besMaxFileSize'],// maximum file size in bytes
'onComplete'=>"js:function(){ $.fn.yiiListView.update('listaAllegati'); }",
'messages'=>array(
'typeError'=>"E' possibile caricare solo {extensions}!",
'sizeError'=>"{file} è troppo grande. La dimensione massima consentita è {sizeLimit}.",
'emptyError'=>"{file} è stato caricato un file vuoto.",
),
)
));
and the yiiListView (on the same modal form)
$config = array('keyField' => 'id_allegato', 'id'=>$model->id);
$dataProvider = new CArrayDataProvider($rawData=$model->allegati, $config);
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'id'=>'listaAllegati',
'itemsTagName'=>'ul',
'itemView'=>'/allegati/_bes_view',
));
...other form tags...
Thanks in advance!