Skip to content
Browse files

fixed #1241 - Deprecate net.liftweb.builtin.snippet.A

** Changed SHtml.a not to use the builtin A object, but to use fmapFunc instead
  • Loading branch information...
1 parent 6289a10 commit b8983ffbf9566d109717fed6bd5f85148b38b6cd @fmpwizard fmpwizard committed with indrajitr
View
12 web/webkit/src/main/scala/net/liftweb/builtin/snippet/A.scala
@@ -23,12 +23,24 @@ import net.liftweb.http._
import net.liftweb.http.js._
import net.liftweb.util._
+@deprecated("Use any of the ajax methods in SHtml instead.")
object A extends DispatchSnippet {
def dispatch : DispatchIt = {
case _ => render _
}
+ /**
+ * Usage:
+ *
+ * <pre name="code" class="xml"
+ * def a(func: () => JsCmd, body: NodeSeq, attrs: ElemAttr*): Elem = {
+ * val key = formFuncName
+ * addFunctionMap(key, ((a: List[String]) => func()))
+ * attrs.foldLeft(&lt;lift:a key={key}>{body}&lt;/lift:a>)(_ % _)
+ * }
+ * </pre>
+ */
def render(kids: NodeSeq) : NodeSeq = Elem(null, "a", addAjaxHREF(), TopScope, kids :_*)
private def addAjaxHREF(): MetaData = {
View
2 web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala
@@ -1685,7 +1685,7 @@ class LiftRules() extends Factory with FormVendor with LazyLoggable {
Map("CSS" -> CSS, "Msgs" -> Msgs, "Msg" -> Msg,
"Menu" -> Menu, "css" -> CSS, "msgs" -> Msgs, "msg" -> Msg,
"menu" -> Menu,
- "a" -> A, "children" -> Children,
+ "children" -> Children,
"comet" -> Comet, "form" -> Form, "ignore" -> Ignore, "loc" -> Loc,
"surround" -> Surround,
"test_cond" -> TestCond,
View
5 web/webkit/src/main/scala/net/liftweb/http/SHtml.scala
@@ -523,9 +523,8 @@ trait SHtml {
* @param attrs - the anchor node attributes
*/
def a(func: () => JsCmd, body: NodeSeq, attrs: ElemAttr*): Elem = {
- val key = formFuncName
- addFunctionMap(key, ((a: List[String]) => func()))
- attrs.foldLeft(<lift:a key={key}>{body}</lift:a>)(_ % _)
+ attrs.foldLeft(fmapFunc((func))(name =>
+ <a href="javascript://" onclick={makeAjaxCall(Str(name + "=true")).toJsCmd + "; return false;"}>{body}</a>))(_ % _)
}
/**

0 comments on commit b8983ff

Please sign in to comment.
Something went wrong with that request. Please try again.