• 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.

Help with updateDom

Scheduled Pinned Locked Moved Development
11 Posts 3 Posters 1.3k Views 3 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 Offline
    sdetweil @mumblebaj
    last edited by Mar 3, 2023, 1:46 PM

    @mumblebaj you don’t HAVE to create new elements on refresh, save the wrapper div and it’s tree.

    check on next getDom if it exists and do whatever to update

    I do this on a few to eliminate the flash of content change. I only ever build the content in getDom()

    updateDom() is just the trigger to mm to call your getDom() to get new content

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    1 Reply Last reply Reply Quote 0
    • M Offline
      MMRIZE @mumblebaj
      last edited by MMRIZE Mar 3, 2023, 4:37 PM Mar 3, 2023, 4:37 PM

      @mumblebaj said in Help with updateDom:

      but what I am trying to avoid is that when I start the mirror, all modules stay active on the 1st screen instead of hiding the modules I don’t want active on the 1st screen. I am using MMM-pages for this. Because there is a delay in the data being returned it causes this issue.

      Hmmm. I think hiddenOnStartup option of the module configuration would be what you really consider.

      S 1 Reply Last reply Mar 3, 2023, 5:36 PM Reply Quote 0
      • S Offline
        sdetweil @MMRIZE
        last edited by sdetweil Apr 8, 2025, 11:59 PM Mar 3, 2023, 5:36 PM

        https://forum.magicmirror.builders/uid/6639 also. you don’t HAVE to show any content. you can return an empty div and mm is happy

        you should also keep track of your hidden state (suspend/resume) and not call updateDom while hidden… so u won’t generate any content while pages has u hidden

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        M 1 Reply Last reply Mar 4, 2023, 2:53 PM Reply Quote 0
        • M Offline
          mumblebaj Module Developer @sdetweil
          last edited by Mar 4, 2023, 2:53 PM

          @sdetweil The biggest issue is that I need to set arrows based on data being returned. I.e. Arrow will go up depending on the data or it points down based on the data. That is where I am stuck. How do I set those back into the wrapper based on the data.

          generateSolarLine: function() {
              var ppvData = parseInt(this.growattData[0].ppv1) + parseInt(this.growattData[0].ppv2);
              solarLabel.innerHTML =  `Solar: ${ppvData}W`;
              if(ppvData > 0) {
                  solarLine.classList.add("active");
          
                  const solarArrowOut = document.createElement("i");
                  solarArrowOut.classList.add("arrow", "down", "active");
                  solarLine.appendChild(solarArrowOut);
              } else {
                  solarLine.classList.add("dimmed");
              }
              return solarLine;
          },
          

          Bases on the value of ppvData I am setting which way the arrow points etc. Doing all the work in the getDom gives issues

          Check out my modules at: https://github.com/mumblebaj?tab=repositories

          S 1 Reply Last reply Mar 4, 2023, 3:01 PM Reply Quote 0
          • S Offline
            sdetweil @mumblebaj
            last edited by Mar 4, 2023, 3:01 PM

            @mumblebaj

            save solarArrowOut as a module instance variable and redo it’s attributes when u need to.
            instead of creating it fresh ever time

            this means all the stuff around it should be stable too…

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            M 1 Reply Last reply Mar 6, 2023, 5:43 PM Reply Quote 0
            • M Offline
              mumblebaj Module Developer @sdetweil
              last edited by Mar 6, 2023, 5:43 PM

              @sdetweil Thanks Sam. Managed to resolve this. Everything works fine now and plays well with the other modules.

              Check out my modules at: https://github.com/mumblebaj?tab=repositories

              1 Reply Last reply Reply Quote 1
              • 1
              • 2
              • 1 / 2
              1 / 2
              • First post
                10/11
                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