Skip to content

What is the correct usage of 'window.Confirm'? #13

Answered by Splizard
SteveMaybe asked this question in Q&A
Discussion options

You must be logged in to vote

Yep, that works, however you are using the low-level JS scripting API.
Using the client package's If function, you can achieve the same thing with more clarity.
https://pkg.go.dev/qlova.org/seed@v0.3.1/client#If

package main

import (
	"qlova.org/seed/client"
	"qlova.org/seed/new/app"
	"qlova.org/seed/new/column"
	"qlova.org/seed/new/text"
	"qlova.org/seed/use/js/window"
)

func main() {
	app.New("Hello World",
		column.New(
			text.Set("Do Thing Maybe"),

			client.OnClick(
				client.If(window.Confirm(client.NewString("Are you sure?")),
					client.Go(func() {
						println("Some server call..")
					}),
				).Else(
					window.Alert(client.NewString("Canceled Action")),
				),
			),
		…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SteveMaybe
Comment options

Answer selected by Splizard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants