Yii Framework Forum: ajaxSubmitButton - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

ajaxSubmitButton Rate Topic: -----

#1 User is offline   JMC 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 16-December 09
  • Location:Nederlands, Den Haag

Posted 08 February 2010 - 06:14 AM

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';)
	var new_name = jQuery('#documents_filename'+id).value;
	jQuery('#file_document'+id).innerHTML(new_name);
}



Thanks!
I bring the sunshine baby... wherever I go =)
0

#2 User is offline   soeperees 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 26-October 09
  • Location:The Hague, The Netherlands

Posted 08 February 2010 - 04:29 PM

Hey JMC,
You might have
'enableCsrfValidation'=>true,
in your main config.
Disable that and it will work like a charm ;-)

You also might change
'type'=>'POST'
to
'type'=>'GET'
.
If you can't figure it out, just ask your favourite colleague ;-)
0

#3 User is offline   JMC 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 16-December 09
  • Location:Nederlands, Den Haag

Posted 09 February 2010 - 02:25 AM

View Postsoeperees, on 08 February 2010 - 04:29 PM, said:

Hey JMC,
You might have
'enableCsrfValidation'=>true,
in your main config.
Disable that and it will work like a charm ;-)

You also might change
'type'=>'POST'
to
'type'=>'GET'
.
If you can't figure it out, just ask your favourite colleague ;-)



Thanks m8, I will try it =)
I bring the sunshine baby... wherever I go =)
0

#4 User is offline   JMC 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 16-December 09
  • Location:Nederlands, Den Haag

Posted 09 February 2010 - 04:21 AM

Unforutnately it didnt make it work. But we find out whats the problem.


this should be the ajaxSubmitbutton's code:

$o .= CHtml::ajaxSubmitButton (
        'AjaxEdit', 
        CController::createUrl('editFileName'), 
        array (
              'type' =>'POST',
              'dataType' => 'html',
              'update' => '#file_document'.$i,
              'complete' => 'function()showHideForm('.$i.')'
        )
 );



I hope it will help some other people as well;)
I bring the sunshine baby... wherever I go =)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users