add missing SHtml.ajaxTextarea...() methods
There is:
but no
Background discussion: http://groups.google.com/group/liftweb/browse_thread/thread/d538728a21e78aa9/d841a33d7ddb8420#d841a33d7ddb8420
I was able to work around this problem from simply copying the SHtml.ajaxText code and changing it to use textarea tags and commenting out the submit on CR line:
thank you
SHtml.text...
SHtml.ajaxText...
SHtml.textarea..
but no
SHtml.ajaxTextarea...
Background discussion: http://groups.google.com/group/liftweb/browse_thread/thread/d538728a21e78aa9/d841a33d7ddb8420#d841a33d7ddb8420
I was able to work around this problem from simply copying the SHtml.ajaxText code and changing it to use textarea tags and commenting out the submit on CR line:
object SHtmlExtension {
import net.liftweb.http.js.{ JsCmd, JsExp }
import net.liftweb.http.js.JsCmds._
import net.liftweb.http.js.JE.{ AnonFunc, Call, JsRaw }
import net.liftweb.http.S.{ contextFuncBuilder, fmapFunc, formFuncName, AFuncHolder, SFuncHolder }
def ajaxTextarea(value: String, func: String => JsCmd, attrs: (String, String)*): Elem =
ajaxTextarea_*(value, false, Empty, SFuncHolder(func), attrs: _*)
def ajaxTextarea(value: String, jsFunc: Call, func: String => JsCmd, attrs: (String, String)*): Elem =
ajaxTextarea_*(value, false, Full(jsFunc), SFuncHolder(func), attrs: _*)
def ajaxTextarea(value: String, ignoreBlur: Boolean, func: String => JsCmd, attrs: (String, String)*): Elem =
ajaxTextarea_*(value, ignoreBlur, Empty, SFuncHolder(func), attrs: _*)
def ajaxTextarea(value: String, ignoreBlur: Boolean, jsFunc: Call, func: String => JsCmd, attrs: (String, String)*): Elem =
ajaxTextarea_*(value, ignoreBlur, Full(jsFunc), SFuncHolder(func), attrs: _*)
private def ajaxTextarea_*(value: String, ignoreBlur: Boolean, jsFunc: Box[Call], func: AFuncHolder, attrs: (String, String)*): Elem = {
val raw = (funcName: String, value: String) => JsRaw("'" + funcName + "=' + encodeURIComponent(" + value + ".value)")
val key = formFuncName
fmapFunc(contextFuncBuilder(func)) {
funcName =>
(attrs.foldLeft(<textarea>{value}</textarea>)(_ % _)) %
//("onkeypress" -> """liftUtils.lift_blurIfReturn(event)""") %
(if (ignoreBlur) scala.xml.Null else
("onblur" -> (jsFunc match {
case Full(f) => JsCrVar(key, JsRaw("this")) & deferCall(raw(funcName, key), f)
case _ => makeAjaxCall(raw(funcName, "this"))
})
))
}
}
// copied from SHtml because it is private there
private def deferCall(data: JsExp, jsFunc: Call): Call =
Call(jsFunc.function, (jsFunc.params ++ List(AnonFunc(makeAjaxCall(data)))): _*)
}
thank you
Leave a comment
(In revision:53c90d6c049371e74c225ba1d0a66164818ee51a) Closes #536. Added ajax and json Textarea
Branch: master
Branch: master