app-body.js template, I call
$(document).foundation(); in the onRendered method – often with a setTimeout() – in order to initialize it on the DOM that gets loaded dynamically. It works fine if I go directly to the app, but if I load it in a new tab, wait a few seconds, and then switch over to that tab, none of it is loaded (even if there is a longer setTimeout() calling
$(document).foundation() after I switch to the new tab).
When I open the browser console locally, I don’t get an error printed out when I type in
$(document), but on the live version I get the following error:
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDocument]' is not a valid selector
I’m not sure if this is a jQuery error or just a foundation error, but it’s reproducible both locally and on production. Any ideas how I could fix it?