Many thanks Antonio!
I was actually just coming here to paste the method that I had worked
out to do this, it is very similar to what you suggested, but perhaps
not so flexible:
HTML:
<lift:CalendarController.listeners>
<script type="text/javascript">
$(function() {
$('#datePicker').datepicker({
dateFormat: 'yy-mm-dd',
onSelect: function(dateText, inst) { <element:fn/> }
});
});
</script>
<element:textField/>
</lift:CalendarController.listeners>
SCALA:
class CalendarController {
def listeners(xhtml: NodeSeq): NodeSeq = {
var (fn, fnbody) = SHtml.ajaxCall(JsVar("dateText"), dateText =>
{ SetHtml("dateText", Text(dateText)) })
Helpers.bind("element", xhtml,
"fn" -> fnbody.toJsCmd,
"textField" -> <b id="dateText"/>)
}
}
But I like your method more, of actually creating and emitting a
separate javascript function. However, I do have one, probably totally
newbie question, where does the "Function" function come from? I am
guessing that it is not the scala "Function", mostly since that
doesn't compile for me. with the following line:
var fnd = Function("dateSelected", List("dateText"),
SHtml.ajaxCall(JsVar("dateText"), dateText => { SetHtml("dateText",
Text(dateText)) })._2)
I get the error "scala{type}.Function{object Function} of type object
Function does not take parameters"
Thanks again!
Cheers,
Paul
On Jan 11, 2:05 am, Antonio Salazar Cardozo <
savedfastc...@gmail.com>
wrote: