halfmoonui/halfmoon

Sticky Alerts (Unhandled Rejection (TypeError): Cannot read property 'insertBefore' of undefined)

timbogdanov opened this issue · 1 comments

Came accross an issue with sticky alerts, I believe this is the correct set up for them, I read and re-read the docs. When ever I try to run a sticky alert I get an error, see below.

image
image
image

Maybe your HTML is being loaded after halfmoon initialization. halfmoon fill stickyAlerts on object initialization using:

{
  ...
  stickyAlerts: document.getElementsByClassName("sticky-alerts")[0],
  ...

Maybe this can solve, but without a code sandbox to try it, I'm not sure. On line 22:

  halfmoon.stickyAlerts = document.getElementsByClassName("sticky-alerts")[0]
  halfmoon.initStickyAlert(...)