Hi Matt,
Thank for your post, my problem is almost solve. Once i add the fourth argument to true and add the include jQuery, the EAjaxUpload is work. CJuiDialog + EAjaxUpload is almost work. Only got a bit bug that i still nt able to solve yet. I have call function to trigger CJuiDialog to close but error is occor, the close script is like below:
$('#uploadBox').dialog('close');
Here the js error:
$(
[Break On This Error] $('#uploadBox').dialog('close');
This is the 1st problem:
Here is show my script:
View:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'uploadBox',
'options'=>array(
//'title'=>'Upload Image',
'autoOpen'=>false,
'width'=>'auto',
),
));
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
<script type="text/javascript">
function closeCJuiDialog(){
$('#uploadBox').dialog('close');
}
</script>
renderPartial View
<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>
<?php
$form=$this->beginWidget('CActiveForm', array(
'id'=>'seller-form',
'enableAjaxValidation'=>true,
'htmlOptions'=>array('enctype'=>'multipart/form-data','name'=>'productListing','OnSubmit'=>'return CheckForm();'),
));
?>
<?php
$this->Widget('ext.EAjaxUpload.EAjaxUpload',
array(
'id'=>'uploadFile',
'config'=>array(
'action'=>$this->createUrl('sell/uploadImageFile',array("a"=>$a)),
'allowedExtensions'=>array("jpg","jpeg","gif","png"),//array("jpg","jpeg","gif","exe","mov" and etc...
'sizeLimit'=>10*1024*1024,// maximum file size in bytes
'minSizeLimit'=>1*5*1024,// minimum file size in bytes
'onComplete'=>"js:function(id, fileName, responseJSON){
alert(responseJSON['counter']);
closeCJuiDialog();
}",
),
));
?>
<?php
$this->endWidget();
?>
Controller
public function actionUploadImageFile(){
$value = $_GET['a'];
//echo $value;
//exit;
Yii::import("ext.EAjaxUpload.qqFileUploader");
$folder=Yii::app()->basePath.'/images/';// folder for uploaded files
$allowedExtensions = array("jpg","jpeg","gif","png");//array("jpg","jpeg","gif","exe","mov" and etc...
$sizeLimit = 0.5 * 1024 * 1024;// maximum file size in bytes
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload($folder,$value);
$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
echo $result;// it's array
}
public function actionLoadDialog(){
echo CJSON::encode(array(
'counter'=>$this->renderPartial('uploadImage',array('a'=>'5'),true,true),
'server'=>$_POST['server'],
'productType'=>$_POST['productType'],
));
}
Now the value is able to pass, only the last part once upload image was done, the trigger close cause js error.