Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated post

  • Loading branch information...
commit 17669646cc3d1538452cd284595a3b177aeb9bf9 1 parent 79aaa63
@tsloughter authored
View
2  lib/bcmvc_web/priv/controllers/todos_controller.coffee
@@ -15,4 +15,4 @@ class TodoMVC.TodosController extends Batman.Controller
create: =>
@emptyTodo.save (error, record) =>
- @set 'emptyTodo', new TodoMVC.Todo()
+ @set 'emptyTodo', new TodoMVC
View
6 lib/bcmvc_web/priv/index.html
@@ -30,7 +30,7 @@
data-event-doubleclick="controllers.todos.edit"
data-addclass-completed="todo.isDone">
<div class="view">
- <input class="toggle" type="checkbox" data-bind="todo.isDone" data-event-click="todo.save"/>
+ <input class="toggle" type="checkbox" data-bind="todo.isDone" data-event-change="todo.save"/>
<label data-bind="todo.body"></label>
<button class="destroy" data-event-click="todo.destroy"></button>
</div>
@@ -42,7 +42,7 @@
<!-- This footer should hidden by default and shown when there are todos -->
<footer id="footer">
<!-- This should be `0 items left` by default -->
- <span id="todo-count"><strong data-bind="Todo.left.length"></strong> items left</span>
+ <span id="todo-count"><strong data-bind="Todo.all.length"></strong> items left</span>
<!-- Remove this if you don't implement routing -->
<ul id="filters">
<li>
@@ -56,7 +56,7 @@
</li>
</ul>
<button id="clear-completed">Clear completed
- (<span data-bind="Todo.done.length"></span>)</button>
+ (<span data-bind="Todo.done"></span>)</button>
</footer>
</section>
<footer id="info">
View
7 lib/bcmvc_web/src/bcmvc_todo_handler.erl
@@ -25,7 +25,12 @@ process_post(Req, State) ->
{ok, Body, Req1} = cowboy_http_req:body(Req),
Todo = bcmvc_model_todo:to_record(Body),
bcmvc_model_todo:save(Todo),
- {true, Req1, State}.
+
+ NewId = bcmvc_model_todo:get(id, Todo),
+ {ok, Req2} = cowboy_http_req:set_resp_header(
+ <<"Location">>, <<"/todos/", NewId/binary>>, Req1),
+
+ {true, Req2, State}.
delete_resource(Req, State) ->
{TodoId, Req1} = cowboy_http_req:binding(todo, Req),
Please sign in to comment.
Something went wrong with that request. Please try again.