Hi,
I have a problem with this ajaxSubmitButton thingy. The code in the controller which called by ajax, working properly(file renameing), but its not updating the field in the browser.
I checked my ajax output with firebug, and its seems okay, I got back the 200 code, and after that, i supposed that the js script which is defined in the success property of ajax should run. But its also doesnt do anything at all.
Does anybody know what can be the problem?
i have this in my view:
$o .= '<div id="file_document'.$i.'">'.$document['file_name'].'</div>'.$eol;
$o .= '</h3>'.$eol;
$o .= '<div id="edit_file_document'.$i.'" class="button_edit_filename">'.$eol;
$o .= CHtml::beginForm();
$o .= CHtml::textField('documents_filename'.$i, $document['file_name'], array('class'=>'editfiletext',));
$o .= CHtml::hiddenField('documents_extension'.$i, $document['file_extension']);
$o .= CHtml::hiddenField('documents_origignalfile'.$i, $document['file_name'].'.'.$document['file_extension']);
$o .= CHtml::hiddenField('documents_projectdir'.$i, $project->name);
$o .= CHtml::ajaxSubmitButton (
'AjaxEdit',
CController::createUrl('editFileName'),
array (
'ajax' => array(
'type' =>'POST',
'dataType' => 'html',
'update' => '#file_document'.$i,
'complete' => 'function()showHideForm('.$i.')'
'success' => 'function(){updateFileName('.$i.')}',
),
)
);
$o .= CHtml::endForm();
echo $o;
and I have this in my controller:
public function actionEditFileName(){
$file_new = $base_src .$sub_dir.DIRECTORY_SEPARATOR.$file[$type.'_filename'].'.'.$file[$type.'_extension'];
$file_old = $base_src . $sub_dir.DIRECTORY_SEPARATOR.$file[$type.'_origignalfile'];
rename($file_old, $file_new);
echo 'new filename';
}
and because this update seems to not working i implemented a js solution. at least i thought so it should work but its not working at all either.
i have some js code as well
function showHideForm(id){
$('#edit_file_document' + id).slideToggle("slow");
$('#file_document' + id).slideToggle('slow');
}
function updateFileName(id){
alert('update'<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />
var new_name = jQuery('#documents_filename'+id).value;
jQuery('#file_document'+id).innerHTML(new_name);
}
Thanks!