Last active
August 29, 2015 14:15
-
-
Save chandu0101/976f55973db5ca86b999 to your computer and use it in GitHub Desktop.
select component scalajs-react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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