Commit 508bc8a3 authored by Sindre Sorhus's avatar Sindre Sorhus

Merge pull request #371 from hornairs/fix-355

Fix Issue #355 in Batman with a dynamic binding
parents 4a811d58 14f77b25
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) =>
......
// Generated by CoffeeScript 1.3.1
// Generated by CoffeeScript 1.3.3
(function() {
var Alfred,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Alfred = (function(_super) {
__extends(Alfred, _super);
Alfred.name = 'Alfred';
function Alfred() {
return Alfred.__super__.constructor.apply(this, arguments);
}
......@@ -28,8 +26,6 @@
__extends(TodosController, _super);
TodosController.name = 'TodosController';
function TodosController() {
TodosController.__super__.constructor.apply(this, arguments);
this.set('newTodo', new Alfred.Todo({
......@@ -37,19 +33,27 @@
}));
}
TodosController.prototype.all = function() {
return this.set('currentTodos', Alfred.Todo.get('all'));
};
TodosController.prototype.routingKey = 'todos';
TodosController.prototype.currentTodoSet = 'all';
TodosController.accessor('currentTodos', function() {
return Alfred.Todo.get(this.get('currentTodoSet'));
});
TodosController.prototype.all = function() {};
TodosController.set('currentTodoSet', 'all');
TodosController.prototype.completed = function() {
this.set('currentTodos', Alfred.Todo.get('completed'));
this.set('currentTodoSet', 'completed');
return this.render({
source: 'todos/all'
});
};
TodosController.prototype.active = function() {
this.set('currentTodos', Alfred.Todo.get('active'));
this.set('currentTodoSet', 'active');
return this.render({
source: 'todos/all'
});
......@@ -150,8 +154,6 @@
__extends(Todo, _super);
Todo.name = 'Todo';
function Todo() {
return Todo.__super__.constructor.apply(this, arguments);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment