Skip to content

Commit

Permalink
Adding ajaxEditableSelect to SHtml. Allows users to dynamically add n…
Browse files Browse the repository at this point in the history
…ew selections into an ajaxSelect.
  • Loading branch information
gflanagan authored and fmpwizard committed Jan 24, 2013
1 parent 186836e commit 40253c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,9 @@ Chris Williams

### Email: ###
chris dot williams @ joulebug dot com

### Name: ###
Gregory Flanagan

### Email: ###
gregmflanagan at gmail dot com
19 changes: 19 additions & 0 deletions web/webkit/src/main/scala/net/liftweb/http/SHtml.scala
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,25 @@ trait SHtml {
}

ajaxSelect(options, deflt, func, attributes: _*)
=======
val id = nextFuncName
val textOpt = nextFuncName
val idAttr = Seq(ElemAttr.pairToBasic("id", id))
val options = opts :+ (textOpt , "New Element")
var _options = options

def addId(elem: Elem) = (idAttr.foldLeft(elem)(_ % _))

lazy val func: (String) => JsCmd = (select: String) => {
def text(in: String): JsCmd = {
_options = (in, in) +: _options
Replace(id, addId({ajaxSelect(_options, Some(in), func, attrs: _*)}))
}
if (select == textOpt) Replace(id, addId({ajaxText("", text(_), attrs: _*)})) & Focus(id) else f(select)
}

addId({ajaxSelect(options, deflt, func, attrs: _*)})
>>>>>>> Adding ajaxEditableSelect to SHtml. Allows users to dynamically add new selections into an ajaxSelect.
}

def ajaxSelect(opts: Seq[(String, String)], deflt: Box[String],
Expand Down

0 comments on commit 40253c8

Please sign in to comment.