Created
May 5, 2012 05:53
-
-
Save Otann/2600194 to your computer and use it in GitHub Desktop.
Lift to JavaScript mapping
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
trait JsHandlerSnippet { | |
val defaultFuncName = nextFuncName | |
// This will be called on server-side | |
def handleJs(param: String): JsCmd | |
def script(x: NodeSeq): NodeSeq = { | |
val funcName = S.attr("name") openOr defaultFuncName; | |
Script(ensure & OnLoad(SetExp(JsVar("window.lift", funcName), jsFunc))) | |
} | |
val params = "params" | |
val jsFunc = AnonFunc(params, SHtml.ajaxCall(JsVar(params), handleJs _)._2) | |
val ensure = JsRaw("if (typeof window.lift == 'undefined') window.lift = {}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment