Small release this time, added 2 new JS commands
- h.OnRunInterval(time.Duration, commands ... Command)
Allows you to run JS commands on the specific interval
Usage:
h.Div(
h.OnLoad(
h.RunOnInterval(time.Second,
js.ConsoleLog("this runs a command every 1s"),
js.SetInnerHtml(h.Div()),
js.EvalJs(`alert('you can eval complex js too')`)
),
)
)
- h.RunAfterTimeout(time.Duration, commands ... Command)
Allows you to run JS commands after a specified timeout
h.Div(
h.OnLoad(
h.RunAfterTimeout(time.Second,
js.ConsoleLog("this runs a command once after a second"),
js.SetInnerHtml(h.Div()),
),
)
)
Additional fixes:
Fixes issues where using simple commands such as js.SetText, js.SetInnerHtml were failing when used in things such as Js.EvalCommands due to 'this' not existing. Commands will now always use 'self' if it exists, otherwise 'this'