Created
September 22, 2011 15:28
-
-
Save notyy/1235065 to your computer and use it in GitHub Desktop.
onsubmit def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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