vugu / vugu

Vugu: A modern UI library for Go+WebAssembly (experimental)
https://www.vugu.org
MIT License
4.86k stars 174 forks source link

about multiple level component value's passing #84

Closed itstmyi closed 4 years ago

itstmyi commented 4 years ago

The sample (wasm-test-suite/test-003-prop) is very helpful . A child component can let me get its value by
event.PropString("target", "value") in the child component event's code .

If the component has no event , how can I get its value ? And how can I pass the component value to its root(parent) component ?

Thanks for any information .

bradleypeabody commented 4 years ago

If the component has no event , how can I get its value ?

If you do something like <input type="text" .value="c.TextValue" @change="c.TextValue = event.PropString("target", "value")"/> - assuming TextValue is declared on your component struct, like so:

type MyComponent struct {
    TextValue string `vugu:"data"`
}

The field TextValue should stay updated whenever the DOM text input element is changed and you can just use c.TextField

And how can I pass the component value to its root(parent) component ?

For this I think we still need another feature which is "component to component events" - not yet implemented. I will also try to hit this as soon as possible. #7

itstmyi commented 4 years ago

Thanks for the answer .