hi,
this is my first try with ajax and 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 (with ajax) 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 the ajax-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 the ajax button
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 (no ajax), then everything is
fine and the current content of the textarea is read and saved to the
database later on....
this is the function, the ajax-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
-~----------~----~----~----~------~----~------~--~---