Writing Golang app using github.com/zserge/lorca
package.
This binds golang funcs to Javascript.
I have HTML with text input and submit button which should pass the text input as an arg into the Javascript binding. It looks as follows:
<input type="text" name="MACADD" style="height:20px; width:210px">
<input type="submit" value="submit" onclick="JSBINDFUNC(MACADD)">
The JSBINDFUNC
takes golang type string
for input.
When I hit submit, it should be passing the text entered for MACADD
as an arg into the JSBINDFUNC
func.
However, I'm coming back with the err
exception":{"type":"string","value":"json: cannot unmarshal object into Go value of type string"}
Needing this object
to become golang string
.
More complete snip:
package main
import (
"fmt"
"log"
"net/url"
"github.com/zserge/lorca"
)
func main() {
ui, err := lorca.New("data:text/html,"+url.PathEscape(`
<html>
<form action="/action_page.php">
MAC Address:<br>
<input type="text" name="MACADD" style="height:20px; width:210px">
<input type="submit" value="Submit" onclick="JSBINDFUNC(MACADD)">
</form>
</body>
</html>
`), "", 480, 320)
if err != nil {
log.Fatal(err)
}
//ui.Bind implemented @ https://github.com/zserge/lorca/blob/master/ui.go#L110
ui.Bind("JSBINDFUNC", func(MAC string) {
fmt.Println(MAC)
return
})
defer ui.Close()
<-ui.Done()
}