I had a related problem: I want to render , say, a table of categories
in the view, and then i want to use an ajax submission to update that
table again. I created the table as an element included in the view,
of course. in order to avoid writing a view for every different
element that i want to update through an ajax call, i created a
'proxy' view:
element_to_ajax.thtml
<?
echo $this->renderElement($element, $elementData);
?>
and i use this handy function to render the element through ajax from
the controller:
controller.php:
private function renderElementAsAjax($element, $elementData)
{
$this->set('elementData', $elementData);
$this->set('element', $element);
$this->render('element_to_ajax', 'ajax');
}
so, basically, i only do the edits on the element files now, and i
render the element 'directly' from the controller like this:
function ajaxRefreshTable()
{
...
$elementData = array(
'categories'=>$video['Category'],
'vid'=>$vid,
);
$this->renderElementAsAjax('table_element', $elementData);
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---