from SHtml:
def ajaxSubmit(value: String, func: () => JsCmd, attrs: ElemAttr*): Elem = {
val funcName = "z" + Helpers.nextFuncName
addFunctionMap(funcName, contextFuncBuilder(func))
(attrs.foldLeft(<input type="submit" name={funcName}/>)(_ % _)) %
new UnprefixedAttribute("value", Text(value), Null) %
("onclick" -> ("liftAjax.lift_uriSuffix = '"+funcName+"=_';
return true;"))
}
It seemed I have had the same need since I found this one in my "lift-utils":
/**
* ajax submit that does some js before sending
*/
def ajaxSubmit(value: String, before: JsCmd, func: () => JsCmd,
attrs: ElemAttr*): Elem = {
val funcName = "z" + Helpers.nextFuncName
addFunctionMap(funcName, contextFuncBuilder(func))
(attrs.foldLeft(<input type="submit" name={ funcName }/>)((a, b)
=> b.apply(a))) %
new UnprefixedAttribute("value", Text(value), Null) %
new UnprefixedAttribute("onclick", (before.toJsCmd + ";
liftAjax.lift_uriSuffix = '" + funcName + "=_'; return true;"), Null)
}
Thanks,
Viktor
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
Thanks for sharing that Viktor!
Diego
--
Diego Medina
Lift/Scala Developer
di...@fmpwizard.com
http://www.fmpwizard.com
that looks neat
ticket created
http://www.assembla.com/spaces/liftweb/tickets/1187-general-before-after-javascript-mechanism
Thanks
Diego
Viktor - Thank you for sharing that bit of code, looks very nice.
David - I can open a ticket for this.