Reloading macros / widgets on page refresh

Hi, I am defining macros/widgets in an external js file (with SugarCube.Macro.Add(...) However I noticed that if I refresh the page, these widgets are not being reloaded and the rendering of the passage fails. It says that the Macro does not exist.

This does not seem desirable. How can I make sure that the widgets are being reloaded when I hit refresh? I tried hooking up the :passageInit event but it does not fire on page refresh.

I do not recommend using the SugarCube debugging interface for anything other than debugging.

I’m unsure how you’re loading your “external js file”, but code meant to be executed within SugarCube’s scope really should be in your JavaScript section—Story JavaScript or the equivalent. If you’re loading it asynchronously then that’s likely your problem—i.e., they are loading, just too late for the resumed passage.

As for the event, I don’t think that’s going to help you, but the name is :passageinit—spelling matters, including casing.