Yii Framework Forum: Delay ajaxsubmitbutton's submit for Elrte's textarea update to finish - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Delay ajaxsubmitbutton's submit for Elrte's textarea update to finish Rate Topic: -----

#1 User is offline   damnated 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 01-February 12

Posted 10 February 2012 - 03:06 AM

The title might be somewhat confusing, I'll elaborate.

My form looks something like this:
<!-- form begins -->
<?php echo CHtml::textArea('Page[new][0][text]', '', array('id'=>'Page_new_0_text'));?>

<?php echo CHtml::ajaxSubmitButton('Add text', CHtml::normalizeUrl(array('/page/addtext')), 
array('success'=>'addTextSuccess', 'beforeSend'=>'beforeAddText',), 
array('name'=>'ajaxTextSubmit')); ?>


and in the beforeAddText function, I have
function beforeAddText(){
     $('#Page_new_0_text').elrte('updateSource');      
}


(as seen on elrte.org/redmine/projects/elrte/wiki/JavaScript_API_EN )

I'm using elrte-elfinder extension in a setup that adds multiple texts with an Elrte editor into a CGrid and then I submit everything at the end (meanwhile I hide the already added text in hidden fields etc.) with a page reload.

The twist is, that Elrte copies it's content to the hidden textarea only on the onSubmit event, and since I'm using ajax, I have to do it manually in the beforeAddText function. So far so good.
The problem is, the ajax submit occurs before elrte finishes copying it's contents to #Page_new_0_text, and the server receives an empty textarea.
If edit the text and submit again, the server receives the first version of the text, it is basically one version behind.

What this looks like: i.imgur.com/vsnNK.png

Is there a way I could somehow delay the submission or work around this? I can't change the way the submission occurs.
0

#2 User is offline   damnated 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 01-February 12

Posted 14 February 2012 - 02:06 AM

I solved this with a regular submit button and it's click event.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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