Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #1188 - Support form=ajax as snippet-attribute

You can now have a snippet invication like:

<form action="#" data-lift="lift:sample?form=ajax">
  <input id="name">
  <input type="submit">
</form>

And lift will do the right thing and convert it into an ajax form (before you had to enclose your form with an extra div and call
data-lift="form.ajax"
  • Loading branch information...
commit a0e844fdb1fd16864fd9d3200e39f1a8cf7aacd8 1 parent ba2c444
@fmpwizard fmpwizard authored
View
2  web/webkit/src/main/scala/net/liftweb/builtin/snippet/Form.scala
@@ -94,7 +94,7 @@ object Form extends DispatchSnippet {
private def addAjaxForm: MetaData = {
val id = Helpers.nextFuncName
- val attr = S.currentAttrsToMetaData(name => name != "id" && name != "onsubmit" && name != "action")
+ val attr = S.currentAttrsToMetaData(name => name != "id" && name != "onsubmit" && name != "action" && name != "form")
val pre = S.attr.~("onsubmit").map(_.text + ";") getOrElse ""
View
7 web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala
@@ -1866,11 +1866,18 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,
case x => x
}
+ case Some("ajax") =>
+ net.liftweb.builtin.snippet.Form.render(ret) match {
+ case e: Elem => e % LiftRules.formAttrs.vend.foldLeft[MetaData](Null)((base, name) => checkAttr(name, attrs, base))
+ case x => x
+ }
+
case Some(ft) =>
<form action={S.uri} method={ft}>
{ret}
</form> %
checkMultiPart(attrs) % LiftRules.formAttrs.vend.foldLeft[MetaData](Null)((base, name) => checkAttr(name, attrs, base))
+
case _ => ret
}
Please sign in to comment.
Something went wrong with that request. Please try again.