At last, got todoIds working

This commit is contained in:
Tyler Renelle 2012-05-02 20:16:40 -04:00
parent d9e8c8f42a
commit 14f34cbe25

View file

@ -17,7 +17,9 @@ get '/', (page, model) ->
money: 0
exp: 0
lvl: 1
todos: []
todos:
0: {id: 0, completed: false, text: 'Example 1'}
todoIds: [0]
getRoom page, model, userId
getRoom = (page, model, userId) ->
@ -30,14 +32,6 @@ getRoom = (page, model, userId) ->
# and their order is stored in an array of ids at '_group.todoIds'
model.refList '_todoList', '_user.todos', '_user.todoIds'
# Add some default todos if this is a new group. Items inserted into
# a refList will automatically get an 'id' property if not specified
unless todoIds.get()
model.push '_todoList',
{text: 'Example todo'},
{text: 'Another example'},
{text: 'This one is done already', completed: true}
# Create a reactive function that automatically keeps '_remaining'
# updated with the number of remaining todos
model.fn '_remaining', '_todoList', (list) ->