I have a Controller in ZF2 that returns a viewModel - if I just hit the controller with the correct URL (index/map) everything works perfect. The view renders.
No, I have a second action in this controller that returns a JSON object to some AJAX calls.
One of the values of the JSON object is the entire rendering result of the first action, to refresh the page.
I do not see how to get the actual rendered value of the first action - I tried to use the var “content” like in normal layout files, but that does not work.
Here is my code, the line that needs help is marked by a comment.
class IndexController extends AbstractActionController
{
function mapAction() {
$viewModel = new ViewModel();
$viewModel–>setTerminal(true)
->setTemplate(‘application/index/map.phtml’);
return $viewModel; }
function nextTurnAction() { $response = $this->mapAction();
return new JsonModel(array( 'response' => $response->content, //THIS LINE NEEDS WORK??? 'Baz' => 'Test' )); }
}