Closed yaodingyd closed 5 years ago
I don't think this is the right solution to a problem.
Eval()
is for one-shot non-persistent operations (e.g. change something in the UI as a reaction to some event in the app).
Bind()
on the other hand is persistent and the binding remains after page reload. The right solution I think would be to bind a Go function, call that from window.onload
and do Eval()
there if you need.
So every persistent UI change will look something like this?
ui.Bind(ui.Eval(`/*DOM manipulation code*/`))
Currently
Eval
would not survive after a reload. I addPage.addScriptToEvaluateOnNewDocument
in ui.Eval to make sure Eval script can run after reload.I think extra document will be needed since script will be run before document ready, so user should wrap their own code inside a
DOMContentLoaded