Skip to content

Instantly share code, notes, and snippets.

@chandu0101
Last active August 29, 2015 14:15
Show Gist options
  • Save chandu0101/976f55973db5ca86b999 to your computer and use it in GitHub Desktop.
Save chandu0101/976f55973db5ca86b999 to your computer and use it in GitHub Desktop.
select component scalajs-react
object DefaultSelect {
class Backend(t: BackendScope[Props, _]) {
def onChange(e:ReactEventI) = t.props.onChange(e.target.value)
}
val component = ReactComponentB[Props]("DefaultSelect")
.stateless
.backend(new Backend(_))
.render((P, S, B) => {
val reactselect: String = "reactselect"
div(cls := reactselect)(
label( htmlFor := reactselect)(strong(P.label)),
select( paddingLeft := "5px", id := reactselect , value := P.value , onChange ==> B.onChange)(
P.options.map(item => option( item))
)
)
})
.build
case class Props(label : String,options : List[String] , value : String , onChange : MTypes.StringUnit)
def apply(ref: js.UndefOr[String] = "", key: js.Any = {},label : String,options : List[String] , value : String , onChange : MTypes.StringUnit) = component.set(key, ref)(Props(label,options,value,onChange))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment