Beispiel #1
0
func mainPage() {

	js.GetDocument().SetTitle("Main Page")
	js.GetDocument().GetBody().SetInnerHTML(html.Div().Children(
		html.H1().Id(h1Id).Text("Click Me"),
		html.A().Href(paths.second).Text("Second page"),
	))

	navUsingH1(paths.second)

}
Beispiel #2
0
func secondPage() {
	js.GetDocument().SetTitle("Second Page")
	js.GetDocument().GetBody().SetInnerHTML(
		html.Div().Children(
			html.H1().Id(h1Id).Text("I am second page"),
			html.A().Href(paths.main).Text("First page"),
		),
	)

	navUsingH1(paths.main)

}
Beispiel #3
0
func navUsingH1(path string) {

	//TODO make this better
	h1 := js.GetDocument().QuerySelector(h1Id)
	h1.AddEventListener("click", func(event *gopherjs.Object) {
		js.NavigateTo(path)
	})
}
Beispiel #4
0
func mainPage() {
	js.GetDocument().SetTitle("Main Page")
	js.GetDocument().GetBody().SetInnerHTML(html.Div().Children(
		html.H1().Text("Hello world"),
	))
}