In NodeJS I have an api that gives me the data for a todo :
app.get('/api/todo/:_id' function (req, res, next) {
Todo.findOne({ _id: req.params._id}, '', function (err, todo) {
res.send(todo);
});
});
Now in Backbone Marionette, I am have loading_view and then I fetch a Todo from Backbone Model using Manager.request("todo:entity", _id). Once the todo is fetch I overwrite this view with new todo_view
Manager.todoPanel.show(loading_view);
var fetching_todo = Manager.request("todo:entity", _id);
$.when(fetching_todo).done(function (todo) {
var todo_view = new Manager.TodoView({
model: todo
});
Manager.todoPanel.show(todo_view);
Now the problem is:
I want to render a view when there is no todo returned. I mean an empty Marionette ItemView. Or in case of BackboneJS what should I return from server for the Backbone to understand that an Empty view has to be returned?
In this case only loading view is shown because if we cannot find a Todo with an _id res.send doesnot send anything.