Thanks,
That does work!
$view_output = $this->render('add')->body());
But I also found another way.
$html_view = new View($this, false);
$view_output = $html_view->render('add');
Is there a difference in either in terms of processing the request? Is 1
more efficient over the other?
Thanks,
Dave
From: [email protected] [mailto:[email protected]] On Behalf
Of majna
Sent: Friday, October 19, 2012 8:46 AM
To: [email protected]
Subject: Re: Render Element with AJAX Request / Response
Hi,
Controller::render() returns CakeResponse object, so try
'html' => $this->render()->body()
On Friday, October 19, 2012 2:56:44 AM UTC+2, advantage+ wrote:
My original function to return a JSON array no longer works with v2.1.3
This worked in 1.3: loaded a form into a modal window
Controller code snip:
if ( empty( $this->data ) ) {
$this->data = $record; //debug shows the $record so there is
data / debug is at 0 now
$response = array(
'status' => true,
'title' => $record['Education']['program'],
'html' => $this->render());
}
$this->_ajaxReturn( $response ); //simply encodes and returns the $response
echo json_encode($response);
But the html data is no longer being rendered into the JSON response. The
fancybox loads but no HTML.
The js for the ADD link in the view calls this js:
$(".add").live('click', function (){
$.fancybox.showActivity();
$.ajax({
type: "GET",
url: $(this).attr("href"),
cache: false,
resetForm: true,
dataType: 'json',
success: function(r) {
$.fancybox({
'autoDimensions' : false,
'opacity' : 1,
'width' : 740,
'margin' : 10,
'padding' : 10,
'content' : r.html});
}
});
return false;
});
The JSON response looks like this:
{"status":true,"title":"Auto Generated For Development","html_view":{}}
Any ideas?
Thanks,
Dave
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.