Skip to content

Instantly share code, notes, and snippets.

@notyy
Created September 22, 2011 15:28
Show Gist options
  • Save notyy/1235065 to your computer and use it in GitHub Desktop.
Save notyy/1235065 to your computer and use it in GitHub Desktop.
onsubmit def
def onSubmit (func: (String) ⇒ Any): (NodeSeq) ⇒ NodeSeq
execute the String function when the form is submitted. This method returns a function that can be applied to form fields (input, button, textarea, select) and the function is executed when the form containing the field is submitted.
object ChatIn {
/**
* The render method in this case returns a function
* that transforms NodeSeq => NodeSeq. In this case,
* the function transforms a form input element by attaching
* behavior to the input. The behavior is to send a message
* to the ChatServer and then returns JavaScript which
* clears the input.
*/
def render = SHtml.onSubmit(s => {
ChatServer ! s
SetValById("chat_in", "")
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment