Skip to content

Change event does not always trigger on dropdowns with bound values #67

@rmehlinger

Description

@rmehlinger

In the following example, $input3's value is bound to the selected option of $input2. Which of $input2's options is selected is bound to $input1. If we manually change the selected value of $input2, $input3's value updates as expected. If we change the value of $input1, $input2's value also updates as expected; however, $input3's does not. I suspect this is because updating $input1 does not directly change the value of $input2, but rather changes the selected attribute on its options.

R.div {}, [
  $input1 = R.input {type: 'number', value: 0}
  $input2 = R.select {}, [
    R.option {value: 1,  selected: bind ->  parseInt($input1.rx('val').get()) > 0}, 'positive'
    R.option {value: 0,  selected: bind ->  parseInt($input1.rx('val').get()) == 0}, 'zero'
    R.option {value: -1, selected: bind -> parseInt($input1.rx('val').get()) < 0}, 'negative'
  ]
  $input3 = R.input {type: 'number', value: bind -> $input2.rx('val').get()}
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions