Skip to content

V1.0.5

Latest
Compare
Choose a tag to compare
@maddalax maddalax released this 16 Nov 14:57
· 21 commits to master since this release

Small release this time, added 2 new JS commands

  1. 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')`)
	  ),
    )
)
  1. 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'