Okay so i recently started to study backbone, so i digg in to the rest controller docs.
Found out if i want to use the template and the rest i need the Hívrid controller.
So my problem is if i specify the rest format in my controller to json it ignores it, second what i dont get if i specify my view in the content just the view is shown but the rest not.
I know im doing something wrong. so my code
<?php
class Controller_Tasks extends Controller_Hybrid {
protected $format = 'json';
public function action_index()
{
$task = Model_Task::find('all');
return $this->response($task);
}
this way i get my results back in json format
but if i do it this way to pas my resutls to the view
class Controller_Tasks extends Controller_Hybrid {
You're using a template content when you don't have a template set. Since you're not using it, that call will do nothing. Also, if you want the JSON data from $task, using $this->response() makes the app send the JSON as the content, setting it as a variable of the view does nothing but send the response object into the view (which is probably not what you want).
Are you trying to embed JSON data in the HTML so that you can use it in the page? Are you trying to create a JSON response for a AJAX call? A more detailed example of what you're trying to achieve might help get you a good answer.
To make your example here do something, try this:
class Controller_Tasks extends \Controller_Hybrid {