Permalink
Browse files

Merge pull request #371 from hornairs/fix-355

Fix Issue #355 in Batman with a dynamic binding
  • Loading branch information...
2 parents 4a811d5 + 14f77b2 commit 508bc8a30742d55c65381ba4a199297f6f40c517 @sindresorhus sindresorhus committed Jan 2, 2013
Showing with 31 additions and 24 deletions.
  1. +16 −11 labs/architecture-examples/batman/js/app.coffee
  2. +15 −13 labs/architecture-examples/batman/js/app.js
@@ -1,23 +1,28 @@
class Alfred extends Batman.App
- @root 'todos#all'
- @route '/completed', 'todos#completed'
- @route '/active', 'todos#active'
+ @root 'todos#all'
+ @route '/completed', 'todos#completed'
+ @route '/active', 'todos#active'
class Alfred.TodosController extends Batman.Controller
constructor: ->
- super
- @set 'newTodo', new Alfred.Todo(completed: false)
+ super
+ @set('newTodo', new Alfred.Todo(completed: false))
- all: ->
- @set 'currentTodos', Alfred.Todo.get('all')
+ routingKey: 'todos'
+ currentTodoSet: 'all'
+
+ @accessor 'currentTodos', -> Alfred.Todo.get(@get('currentTodoSet'))
+
+ all: ->
+ @set('currentTodoSet', 'all')
completed: ->
- @set 'currentTodos', Alfred.Todo.get('completed')
- @render source: 'todos/all'
+ @set 'currentTodoSet', 'completed'
+ @render(source: 'todos/all')
active: ->
- @set 'currentTodos', Alfred.Todo.get('active')
- @render source: 'todos/all'
+ @set 'currentTodoSet', 'active'
+ @render(source: 'todos/all')
createTodo: ->
@get('newTodo').save (err, todo) =>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 508bc8a

Please sign in to comment.