aurelia-materialize-bridge: skeleton-webpack issue Materialize.updateTextFields is not a function

☝️ 13. Dezember 2016 21:50

Materialize seems not to be initialized (again) before the bridge loads. Using md-input in the skeleton-navigation project leads to the error in the title.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Sometimes brute-force helps finding a way… 😏

function waitForMaterialize() {
  return new Promise((resolve, reject) => {
    let iterations = 0;
    const handler = window.setInterval(() => {
      iterations++;
      let ma = (window as any).Materialize;
      if (
        ma.elementOrParentIsFixed &&
        ma.escapeHash &&
        ma.fadeInImage &&
        ma.guid &&
        ma.scrollFire &&
        ma.showStaggeredList &&
        ma.toast &&
        ma.updateTextFields
      ) {
        console.log(`waited ${iterations} iterations for Materialize to finish loading`);
        window.clearInterval(handler);
        resolve();
      }
    }, 1);
  });
}

At the top of configure():

await waitForMaterialize();