Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce special cases for updating input(value := someRx) #10

Open
fdietze opened this issue Mar 27, 2017 · 2 comments
Open

Introduce special cases for updating input(value := someRx) #10

fdietze opened this issue Mar 27, 2017 · 2 comments

Comments

@fdietze
Copy link
Contributor

fdietze commented Mar 27, 2017

Have a look at this example:

val inputValue = Var("test")

document.body.appendChild(
  div(
    input(value := inputValue),
    button(onclick := { () => inputValue() = inputValue.now + "!" }, "append !")
  ).render
)

This produces an input field with initial value test. When clicking the button, it appends a ! to the end of the value. This works well until the value of the input field has been changed manually by the user. This is because the attribute value on the input field can only be used to set the initial value, but not overwrite values set by the user. For updates, the value property of the rendered input DOM-Node needs to be set.

I propose to introduce special cases for this behavior:
input(value := someRx) should update the value property instead of setting the attribute.

I would contribute this change but need some hints on how/where to do this.

@ghost
Copy link

ghost commented Mar 19, 2018

Yes, that would be very nice. Meanwhile I have to use an ugly:
def updateInputCell(i: Int, v: String) = { dom.document.querySelector("#cell" + i).asInstanceOf[domhtml.Input].value = v }
instead of
cells(i)() = v

@fdietze
Copy link
Contributor Author

fdietze commented Mar 19, 2018

I opened this issue a year ago, but it's not relevant for me anymore. I switched to and contributed my wanted features (including this one) to Outwatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant