MacBook Pro
Win a
(for each member of your team)
TODO MVC
with WixCode
Yoav Abrahami
Head of Wix Code
$
TODO MVC
● Database of TODO items
● Dataset to show, modify and add TODO items
● Code for different actions
Database
A Database
Title, completed
Write only
Text Input
TextCheckbox
RepeaterRead / Write
Let’s look at the
code...
triggered when there is a change in the
addTodo dataset state
when clicking enter in the input, trigger
the update process.
We blur from the input to force the
dataset to be updated, at which point
the dataset will trigger an item save
per the above function
save the state of addTodo Dataset to the
database. This saves the new todo item
refresh the todos Dataset, this will
update the repeater with the new item
update the statistics
Because the checkbox is in a repeater,
we need to get the right repeater item
$item represents the current repeater
item
Get the new value from the checkbox
Update the todos dataset with the new
value
Save the todos dataset state to the
database
Query for items without a completed flag
equals true
Set the itemsCount text
show the element only after first
setting statistics to prevent loading
blur
set the todos dataset to show all
elements
Disable / Enable the buttons
filter to show non complete items -
completed not equals true
filter to show complete items - completed
equals true
query all completed items
Remove all completed items
Refresh the todos dataset to update the
repeater
Let’s put it all
together...
Q&A
wix.com/code
Thank You!
Yoav Abrahami
yoav@wix.com
NOV 2 0 1 8
YHack, Yale University

Wix Code - Todo App - Yale Hachathon