Skip to content

Instantly share code, notes, and snippets.

@pjazdzewski1990
Created September 21, 2015 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjazdzewski1990/b3881c2abd185ebbea86 to your computer and use it in GitHub Desktop.
Save pjazdzewski1990/b3881c2abd185ebbea86 to your computer and use it in GitHub Desktop.
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