public function ajaxEdit()
{
$this->viewBuilder()->setLayout(‘ajax’);
$this->set(“phone”, “3199999999”);
$this->render(“/Element/conversao/contatos”);
return;
}
Expectation: the specific element “phone”, reload.
Reality: “Undefined variable: phone”
NOTE: I use ajax perfectly, but when I try to load via ajax ONLY a specific element, I can’t.
The solution i’m using is:
Build the HTML inside the Controller
In Ajax sucess: $(‘my_element’).html(response.html_from_controller)
But this solution is a little ugly…
is there another way?
I think that’s it. PHP is the server side html generator, so once the page is loaded its all back to you to control. You could put it in an iframe driven by another controller/action, and refresh it. That allows you to design the page layout back in the PHP. It also means the AJAX reply need only be “Done!” and the refreshed iframe will build from the CakePHP. There may be a cleverer way, but that’ll work.
You have a page, which has a template, which is created by using a number of elements? And now you want to update the content of just one section, which is generated from a particular element? Your Ajax call would presumably have a template which simply outputs a single element.
If your situation isn’t quite like this, maybe this is still enough to get you on the right track?