Yii Eajaxupload и cJuiDialog
Кнопка Eajaxupload не отображается в CjuiDialog, но хорошо работает в стандартной форме.
посмотреть Entradas:
<?php
$this->widget('ext.EAjaxUpload.EAjaxUpload', array(
'id'=>'image',
'config'=>array(
'action'=>Yii::app()->createUrl('/entradas/upload'),
'allowedExtensions'=>array("jpg", "jpeg", "png", "gif"),
'sizeLimit'=>8*1024*1024,// maximum file size in bytes
'onSubmit'=>"js:function(file, extension) {
$('div.preview').addClass('loading');
}",
'onComplete'=>"js:function(file, response, responseJSON) {
$('#thumb').load(function(){
$('div.preview').removeClass('loading');
$('#thumb').unbind();
$('#Associazioni_logo').val(responseJSON['filename']);
});
$('#thumb').attr('src', '/../images/temp/'+responseJSON['filename']);
}",
'messages'=>array(
'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",
'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",
'emptyError'=>"{file} is empty, please select files again without it.",
'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."
),
)
));
?>
контроллер создания Entrada
public function actionCreate()
{
$model=new Entradas;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Entradas']))
{
$model->attributes=$_POST['Entradas'];
if($model->save()){
if (Yii::app()->request->isAjaxRequest)
{
echo CJSON::encode(array(
'status'=>'success',
'div'=>"Tu creación fue exitosa."
));
exit;
}
else
$this->redirect('/site/index');
}
}
if (Yii::app()->request->isAjaxRequest)
{
echo CJSON::encode(array(
'status'=>'failure',
'div'=>$this->renderPartial('_form', array('model'=>$model), true)));
exit;
}
else
$this->render('create',array('model'=>$model,));
}
Это не работает
$this->renderPartial('_form', array('model'=>$model),false, true)));
Я получаю в отладчике "Пожалуйста, включите JavaScript, чтобы использовать загрузчик файлов".
отсутствует какой-то параметр, в чем проблема?¿?¿
больше информации
ссылка crearEntrada
<li class="ope-add-ent" title="Crear Entradas" onclick="addEntrada(); $('#modal_dialog').dialog('open');"></li>
добавить код вызова AJAX cjudialog функции javascript addEntrada:
echo CHtml::ajax(array(
'url'=>array('/entradas/create','t'=>'ENTRADA'),
'data'=> "js:$(this).serialize()",
'type'=>'post',
'dataType'=>'json',
'success'=>"function(data)
{
if (data.status == 'failure')
{
$('#modal_dialog div.divForForm').html(data.div);
// Here is the trick: on submit-> once again this function!
$('#modal_dialog div.divForForm form').submit(addEntrada);
}
else
{
$('#modal_dialog div.divForForm').html(data.div);
//setTimeout(\"$('#modal_dialog').dialog('close') \",3000);
setTimeout(\"location.reload(true);\",3000);
}
} ",
))?>
и код виджета cjuidialog:
$this->beginWidget('zii.widgets.jui.CJuiDialog', array( // El dialog
'id'=>'modal_dialog',
'options'=>array(
'title'=>'',
'autoOpen'=>false,
'modal'=>true,
'width'=>550,
'height'=>485,
),
));