ammgws / ammcon-frontend

Frontend for AmmCon home automation project
Other
1 stars 0 forks source link

bug where moment.js overwrites DOM #11

Closed ammgws closed 7 years ago

ammgws commented 7 years ago

Current usage of moment.js involves using document.write to add the below javascript to the page: <script>\ndocument.write(moment(\"%s\").%s);\n</script>

However calling document.write() on a closed document stream (i.e. after page is loaded) automatically calls document.open(), which will clear the DOM (source) and results in pages only displaying the result of the moment.js script above when using jQuery Mobile's AJAX page loads.

How to reproduce issue:

  1. Go to AmmCon main page
  2. Open graphs using the side panel
  3. Refresh the page (necessary in order to force AJAX page load of index page)
  4. Click on the link to go back to the main page

When page is overwritten: image When page loads correctly: image