Skip to content

Add bind.radio #75

@Tarmil

Description

@Tarmil

For radio button groups.

module bind =
    val radio : group:string -> thisButtonValue:string -> onChecked:(unit -> unit) -> Attr

// Example use:
let myRadioList model dispatch =
    forEach {1..10} <| fun ix ->
        input [
            bind.radio "mygroup" (string ix) (fun () -> dispatch (SetMyGroup ix))
        ]

// Equivalent to:
let myRadioList model dispatch =
    forEach {1..10} <| fun ix ->
        input [
            attr.``type`` "radio"
            attr.name "mygroup"
            attr.value (string ix)
            on.change (fun args ->
                if (args.Value :?> string) = string ix then
                    dispatch (SetMyGroup ix))
        ]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions