hi,
i found the solution.
reason was, that the textarea was converted by tinyMCE and tinyMCE has
to be told to put the content of the tinyMCE window back into the
original textarea before reading the form fields.

just changed the ajax-submit in cakePHP-style like this:

$ajax->submit($this->requestAction('/gui_labels/get/autosave/nospan'),
array('url' => 'add_user/'.$call_id.'/1', 'update' => 'ajax', 'before'
=> "tinyMCE.execCommand('mceRemoveControl', true,
'MessageContent');tinyMCE.triggerSave()"));?>

and it works.

and the timer driver javascript looks like this (save the content
every 10 minutes):

function myAutoSave(){
        tinyMCE.execCommand('mceRemoveControl', true, 'MessageContent');
        tinyMCE.triggerSave();
        new Ajax.Updater('ajax','/diakonie/messages/add_user/25/1',
{asynchronous:true, evalScripts:true,
parameters:Form.serialize('MessageAddForm'), requestHeaders:['X-
Update', 'ajax']});
        inst = tinyMCE.get('MessageContent');
    tinyMCE.execCommand("selectall", false, null);
    if (tinyMCE.isMSIE) {
        rng = inst.getRng();
        rng.collapse(false);
        rng.select();
    }
    else {
        sel = inst.getSel();
        sel.collapseToEnd();
    }
        window.setTimeout('myAutoSave()', 300000);
  };

  window.setTimeout('myAutoSave()', 300000);

denada,
sven

On Jan 14, 10:28 pm, dragstar-650 <[EMAIL PROTECTED]> wrote:
> hi,
> this is my first try withajaxand i get stucked right now.
> i have a form with a textarea und 3 submit-buttons.
> the first one makes a normal save in te database.
> the second one save the content in the database but marks it as not
> final.
> the third one should be the best (withajax) and should although save
> the current content of the textarea in the database and mark it as not
> final.
>
> the problem i have is that the third one always only read the state of
> the content when i'm started editing in this session. all changes to
> the textbox were ignored.
> the rest (changing theajax-update-div with the timestamp of the last
> save without reload of the page) works fine
>
> i tried something around and reached this version (not working of
> course...):
> this is the function called on the submit of the form:
> $ajax= 1 only when submitted with theajaxbutton
>
> function add_user($call_id = null, $ajax= null) {
>                 if ($ajax) {
>                         $this->cleanUpFields();
> //                      var_dump($this->data);
>                         $this->Session->write('data', $this->params['data']);
>                         $this->Session->write('content', 
> $this->params['data']['Message']
> ['content']);
>                         //$this->Session->write('data', $this->data);
>                         
> //$this->redirect('/messages/content_refresh_user/'.$call_id);
>                         exit();
>                 }
>                 ...
>                 if (empty($this->data)) {
>                 ...
>                 } else {
>                         $this->cleanUpFields();
>                         //welcher submit wurde betätigt?
>                         if (isset($_POST['finalsave'])) {
>                            $target = '/calls/index_user_calls';
>                            $this->data['Message']['final'] = 1;
>                         } elseif (isset($_POST['autosave'])) {
>                            $target = '/messages/add_user/'.$call_id;
>                            $this->data['Message']['final'] = 0;
>                         }
>                         $call=$this->Call->findById($call_id);
>                         if (!$this->data['Message']['content']...
>
> when i reach this point in normal submit (noajax), then everything is
> fine and the current content of the textarea is read and saved to the
> database later on....
>
> this is the function, theajax-stuff should happen:
>
>         function content_refresh_user($call_id = null) {
>                 if (!$call_id) { exit(); }
>                 $this->cleanUpFields();
>                 $data= $this->Session->read('data');
>                 $content = $this->Session->read('content');
>                 //$this->params['data']['Message']['final'] = 0;
>                 if (!$data['Message']['content'] or (strlen($data['Message']
> ['content'])==0)) {
>                         $this->set('msg', 
> $this->requestAction('/gui_labels/get/
> messages_add_missing_content'));
>                         $this->render('content_refresh_error', 'ajax');
>                         exit();
>                 } else {
>                         $call=$this->Call->findById($call_id);
>                         if 
> (!$this->Client->findByLogin($call['Call']['login'])) {
>                                 //falls in der zwischenzeit der call gelöscht 
> wurde
>                                 
> $this->Session->setFlash($this->requestAction('/gui_labels/get/
> users_login_deleted'));
>                                 
> $this->redirect('/calls/index_user_calls_closed');
>                                 exit();
>                         } else {
>                                 $data['Message']['call_id'] = $call_id;
>                                 $data['Message']['originator_id'] = 2; // 
> Absender Berater
>
>                                 //und verschlüsseln mit dem call-key
>                                 //$content = $data['Message']['content'];
>                                 $data['Message']['content'] = 
> $this->RtOpenssl->encrypt($content,
> $this->Call->getPublicKey($call_id),
>                                                                               
>                                                                           
> 'messages/add_client: Message with Call-Pub');
>
>                                 if ($this->Message->save($data)) {
>                                         
> $this->Call->setFields($this->Session->read('call_id'),
> array('datetime_lastcontact_intern=NOW()'));
>                                         $this->set('id', 
> $data['Message']['id']);
>                                         $this->set('content', $content);
>                                         $this->render('content_refresh_user', 
> 'ajax');
>                                         exit();
>                                 }
>                                 $this->set('msg', 'Fehler beim speichern');
>                                 $this->render('content_refresh_error', 
> 'ajax');
>                                 exit();
>                         }
>                 }
>                 $this->set('msg', 'Undefinierter Fehler beim speichern');
>                 $this->render('content_refresh_error', 'ajax');
>         }
>
> i hope someone understands what i want (German: Zwischenspeichern) an
> have THE tip for me ;-)
>
> thanks a lot!
>
> sven
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to