I’ve started a new site and added a few components to it. When I noticed $w.onReady didn’t run I opened the browser’s console to find this error:
Uncaught (in promise) TypeError: Cannot read property ‘SOME_ID’ of null
at createInitHandler.js:190
at Array.map ()
at createInitHandler.js:179
at worker.js:164
at n (wixcode-stores.js:1537)
at Generator._invoke (wixcode-stores.js:1766)
at Generator.e. [as next] (wixcode-stores.js:1589)
at asyncGeneratorStep (fetch.js:466)
at _next (worker.js:126)
at worker.js:126
at new Promise ()
at _processMessage (worker.js:126)
at worker.js:84
at queueUntilAllPrevIsProcessed.js:9
at Array.forEach ()
at queueUntilAllPrevIsProcessed.js:9
at Array.every ()
at o (queueUntilAllPrevIsProcessed.js:8)
at Object.handle (queueUntilAllPrevIsProcessed.js:40)
at worker.js:105
at self.onmessage (worker.js:92)
Searching for SOME_ID I’ve found it defined in an inline script:
var editorModel = {
...
"applications": {
"SOME_ID": {
"controllersCount": ...
...
}
I’ve also tried to start a blank site and added dev tools to get the same effect so it’s not in my code.
In any case my code is:
$w.onReady(() => {
console.log('ready');
});
ready is of course not printed.
Any way to fix or work around this?
EDIT:
This only happens in preview mode. Published site prints ‘ready’ and loads properly…