• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

module updateDom() call limitations

Scheduled Pinned Locked Moved Solved Troubleshooting
5 Posts 2 Posters 1.3k Views 1 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Away
    sdetweil
    last edited by Feb 14, 2019, 4:19 PM

    I was helping update a module, and it just so happened that there were three updateDom() (no delay) calls back to back… and the changes for the last two were not actually applied to the dom (well, no displayed info changed).

    by adding a small delay updateDom(100), everything works, even tho the calls are still back to back…

    anyone have an explanation, is this a limitation, a bug, or a limitation in electron?

    the content was a different icon without flashing and a change of text to blanks… so, pretty significant…

    the app (mmm-voice), completely rebuilt its div contribution to the content, so it would be a significant change… (rip out old, insert new)…

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    1 Reply Last reply Reply Quote 0
    • A Offline
      AxLed Module Developer
      last edited by Feb 14, 2019, 8:28 PM

      @sdetweil
      Maybe not a direct answer to your question, but i found out, that updateDom() is not always needed if you “only” want to update some content.

      As example i have a (inital) div like:

      var Receiverinfo = document.createElement("div");
      Receiverinfo.setAttribute('id','model');
      Receiverinfo.innerHTML = '';
      

      you can change the value/content by

      document.getElementById('model').innerHTML = 'what ever value you want';
      

      AxLED

      1 Reply Last reply Reply Quote 1
      • S Away
        sdetweil
        last edited by Feb 14, 2019, 8:35 PM

        Yes, you can fiddle w the dom directly, but you shouldn’t…

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • S Away
          sdetweil
          last edited by sdetweil Feb 16, 2019, 5:24 PM Feb 16, 2019, 2:32 PM

          so, this turns out to be a side effect of the dom api content update process…

          element.appendChild() is an async call… so the update is NOT complete when the call returns.

          our getDom() routines use this all the time

          updateDom() uses this to check to see if there is an actual content update…
          MM wraps the output of getDom() in ANOTHER div, which is added via appendchild, then adds the getDom() content to THAT div via appendChild()…

          the next updateDom() call comes in calls getDom(), and checks to see if the new content changed… it creates a div, adds the new content via appendChild() and then compares… sadly, both are still just < div>, so they match, no update needed, and the new content is lost…

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 1
          • S Away
            sdetweil
            last edited by Feb 16, 2019, 5:23 PM

            SO, the workaround… NEVER call updateDom() without a minimum count of 2 (as the code divides by 2 inside)
            it does a hide/update/show) (hide/show each get 1/2 the time specified, ie 2/2 =1 each.

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              4/5
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Sam, technical setup by Karsten.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy