Re: ajax question: how can I make the controller decide what element to update?

2008-03-25 Thread Dave J

Hi Marc,

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

ajax question: how can I make the controller decide what element to update?

2008-03-25 Thread MarcS

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
-~--~~~~--~~--~--~---