Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Created March 30, 2011 04:18
Show Gist options
  • Save fmpwizard/893857 to your computer and use it in GitHub Desktop.
Save fmpwizard/893857 to your computer and use it in GitHub Desktop.
def stateDropDown = SHtml.ajaxSelect(
CitiesAndStates.states.map(i => (i, i)),
Full(1.toString),
selected => {
//What to do when you select an entry
Info.selectedState.set(selected)
state= selected
Noop
}
)
def cityDropDown(in: NodeSeq) =
WiringUI.toNode(in, Info.cities, JqWiringSupport.fade)((d, ns) => cityChoice(state))
private def cityChoice(state: String): Elem = {
val cities = CitiesAndStates.citiesFor(state)
val first = cities.head
// make the select "untrusted" because we might put new values
// in the select
untrustedSelect(cities.map(s => (s,s)), Full(first), s => city = s)
}
def idDropDown(in: NodeSeq) =
WiringUI.toNode(in, Info.ids, JqWiringSupport.fade)((d, ns) => idChoice(state))
private def idChoice(state: String): Elem = {
val ids = CitiesAndStates.idsFor(state)
val first = ids.headOption
// make the select "untrusted" because we might put new values
// in the select
untrustedSelect(ids.map(s => (s,s)), first, s => id = s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment