Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    SOLVED module updateDom() call limitations

    Troubleshooting
    2
    5
    754
    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
      sdetweil last edited by

      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)…

      1 Reply Last reply Reply Quote 0
      • A
        AxLed Module Developer last edited by

        @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
          sdetweil last edited by

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

          1 Reply Last reply Reply Quote 0
          • S
            sdetweil last edited by sdetweil

            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…

            1 Reply Last reply Reply Quote 1
            • S
              sdetweil last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy