dtylman / gowd

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs)
MIT License
432 stars 43 forks source link

<select> element on event changes to first option. #2

Closed Demitroi closed 7 years ago

Demitroi commented 7 years ago

I'm developing a GUI app on go

div = gowd.NewElement("div") div.AddHTML(

</select>`, sm)
sm["selecter"].OnEvent(gowd.OnChange, sltChanged)
body.AddElement(div)
gowd.Run(body)

}

func sltChanged(sender gowd.Element, event gowd.EventElement) { body.AddElement(gowd.NewText(event.GetValue())) body.AddElement(gowd.NewElement("br"))

}`

Check it out https://justpaste.it/18xel

That doesn't happen when the "sltChanged" is not called.

//sm["selecter"].OnEvent(gowd.OnChange, sltChanged)

Check it out https://justpaste.it/18xep

Demitroi commented 7 years ago

I want that an option stays selected as the second link.

dtylman commented 7 years ago

looks like a bug

dtylman commented 7 years ago

the problem was that <select> was not considered as input tag and therefore its event data was not processed.

The fix was both in go and the js code, here: https://github.com/dtylman/gowd/blob/master/cmd/template/main.js#L93

Make sure you update your javascript or use the new and fixed js fro template.