Hi Marc,

What if the view is actually a Javascript codeblock which updates the
DOM?  (Since Ajax responses are evaluated in they contain <script>
tags)

For example, the response view might only contain

$('form_div').update('Hello');

or

$('listing_div').update('Hello');


I haven't tried this out, and it seems to be more of a hack, but no
reason why it shouldn't work. Obviously you'd need to replace the IDs
of the DOM elements with variables, and then set those in the
controller as you wanted to do in the first place



On Mar 25, 11:42 pm, MarcS <[EMAIL PROTECTED]> wrote:
> Hi, usually I would use a form like this one
>
>  echo $ajax->form('edit', 'post', array(
>      'model'    => 'model',
>      'url'      => array( 'action' => 'edit'),
>      'update'   => 'element_to_update',
>  ));
>
> but what if, depending on the success of the edit operation, I want to
> update another div?
> For example I would like to update the element 'form_div' when there
> is a validation error when saving the record and the element
> 'listing_div' when the record was saved successfully and I want to
> relfect the changes in the part of my pages that shows info about the
> data set that has just been updated.
>
> What do I put in my controllers and in the views?
>
> what do I have to fill in here and what has to go in the views?
>
> if ($this->Model->save($this->data)) {
>         //some code that will render a view which will update
> 'listing_div'} else {
>
>         //some code that will render a view which will update 'form_div'
>
> }
>
> I tried to google for this but didn't really find anything.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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