Skip to content

Commit d65675b

Browse files
committed
Apply suggestions
1 parent 6de656e commit d65675b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

examples/bind/main.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package main
22

33
import webview "github.com/webview/webview_go"
44

5-
const html = `<html style="background: #1B2845; color: #eee;">
6-
<button onclick="increment();">Tap me</button>
5+
const html = `<html>
6+
<button id="increment">Tap me</button>
77
<div>You tapped <span id="count">0</span> time(s).</div>
88
<script>
9-
const counter = document.getElementById("count")
10-
async function increment() {
11-
const result = await window.Increment()
9+
const incrementBtn = document.getElementById("increment");
10+
const counter = document.getElementById("count");
11+
incrementBtn.addEventListener("click", async () => {
12+
const result = await window.increment()
1213
counter.textContent = result.count;
13-
}
14+
});
1415
</script>
1516
</html>`
1617

@@ -26,7 +27,7 @@ func main() {
2627
w.SetSize(480, 320, webview.HintNone)
2728

2829
// A binding that increments a value and immediately returns the new value.
29-
w.Bind("Increment", func() IncrementResult {
30+
w.Bind("increment", func() IncrementResult {
3031
count++
3132
return IncrementResult{Count: count}
3233
})

0 commit comments

Comments
 (0)