Ok,
Here is what I'm thinking of:
def ajaxButton(text: NodeSeq, jsFunc: Call, func: () => JsCmd,
attrs: (String, String)*): Elem = {
val params = (name: String) => jsFunc.params ++ List(AnonFunc
(makeAjaxCall(Str(name+"=true"))))
attrs.foldLeft(fmapFunc(func)(name =>
<button onclick={(Call(jsFunc.function, params
(name):_*)).toJsCmd + "; return false;"}>{text}</button>))(_ % _)
}
jsFunc impersonates a JavaScript function call. We are appending to
the parameters list specified by the user the actual function that
does the Ajax call.
For exemplification here is a snippet function:
def button(xml: NodeSeq): NodeSeq = {
bind("f", xml,
"show" -> ajaxButton(Text("Press me"), Call("dialog", Str
("a param")), () => {println("pressed"); Noop})
)
}
... and here is the JavaScript function declaration:
<script type="text/javascript">
function dialog(name, theCall) {
alert("Got " + name);
theCall();
}
</script>
.. it could be any JS function from a .js file etc.
In this example the actaul Ajax call is made after clicking OK button
of the alert dialog.
Br's,
Marius
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---