Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
val addButton = button("Add a new task").render
@JSExport
def main(target: html.Div): Unit = {
...
addButton.onclick = (_: MouseEvent) => {
val desc = addDesc.value
val time = Try{ addTime.value.toInt }.toOption.getOrElse(0)
thingsToDo = Task(desc, time) :: thingsToDo
// now you need to refresh the UI
}
...
}
def createDeleteButton(it: Task) = {
val b = button("X").render
b.onclick = (_: MouseEvent) => {
thingsToDo = thingsToDo.filterNot(_ == it)
// now you need to refresh the UI
}
b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment