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.

    UpdateDom not working

    Scheduled Pinned Locked Moved Development
    22 Posts 3 Posters 11.6k 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
      sharmmoh1983
      last edited by

      But in that case all my modules will be appearing on screen which I don’t want and should only appear at voice command

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        j.e.f.f Project Sponsor Module Developer @sharmmoh1983
        last edited by

        @sharmmoh1983 Not the case, especially if you call hide(0). This all happens before a single screen refresh, so you won’t see the module on-screen for a split second before it hides.

        1 Reply Last reply Reply Quote 0
        • S Offline
          sharmmoh1983
          last edited by

          @j-e-f-f
          I want all modules to hide during start

          ? J 2 Replies Last reply Reply Quote 0
          • ? Offline
            A Former User @sharmmoh1983
            last edited by

            @sharmmoh1983 instead of hide, how about using display:none in css?

            1 Reply Last reply Reply Quote 0
            • ? Offline
              A Former User
              last edited by A Former User

              Now i understand whats going on. You had tried to hide modules before dom created.
              My suggetion is;

              1. use css for making modules invisible with display:none on startup.(or cover all modules with temp div which has black background on top level)
              2. after Dom_object_created message received, hide all module with .hide().
              3. then change css again for displaying, or remove the covered div.
              4. then you can use your command.
              1 Reply Last reply Reply Quote 0
              • S Offline
                sharmmoh1983
                last edited by

                @Sean

                I will look into the approach but I don’t want every module to be off , some commanded by voice so can’t make use of css

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sharmmoh1983
                  last edited by

                  @Sean Also updateDOM is also creating DOM first so there should be no issue of DOM getting created or not

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    sharmmoh1983
                    last edited by

                    @Sean @j-e-f-f Thanks for your support… i will try the discussed approach also and come back with my findings

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      j.e.f.f Project Sponsor Module Developer @sharmmoh1983
                      last edited by

                      @sharmmoh1983 said in UpdateDom not working:

                      I want all modules to hide during star

                      Yep you can do it. the MM object has a method called getModules() which will give you all the loaded modules. Example:

                      var modules = MM.getModules();
                      modules.enumerate(function(module) {
                          module.hide(0, {lockString: "yourLockString"});
                      });
                      
                      S 1 Reply Last reply Reply Quote 0
                      • S Offline
                        sharmmoh1983
                        last edited by

                        @j-e-f-f But where it call this as all modules will be loaded simultaneously

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          sharmmoh1983 @j.e.f.f
                          last edited by

                          @j.e.f.f But where to call mentioned code as all modules will be loaded simultaneously

                          J 1 Reply Last reply Reply Quote 0
                          • J Offline
                            j.e.f.f Project Sponsor Module Developer @sharmmoh1983
                            last edited by

                            @sharmmoh1983 call it in your routine that responds to the DOM_OBJECTS_CREATED notification.

                            You can’t hide a module before its Dom exists. When this notification is dispatched it means all modules have started AND their Dom objects have been created for the first time. It’s the earliest opportunity you have to hide any modules.

                            S 1 Reply Last reply Reply Quote 0
                            • S Offline
                              sharmmoh1983 @j.e.f.f
                              last edited by

                              @j.e.f.f I am not generating DOM while start of the module but at voice command and this approach is working individually for the modules but not if all are coupled together So how come it is happening for individual modules

                              J 1 Reply Last reply Reply Quote 0
                              • J Offline
                                j.e.f.f Project Sponsor Module Developer @sharmmoh1983
                                last edited by

                                @sharmmoh1983 all the Dom objects for all modules are created automatically when MagicMirror starts. This is not under your control, even for your own module. Your getDom() routine is called when your module’s Dom object is initially created. This is why it is common to see a conditional in getDom() routines that returns something like a simple string (e.g.: “Loading…”). Once your Dom object has been created, you can call updateDom() at your discretion to make changes to whatever your module displays. If you don’t want your module to display anything, then don’t specify a location in the config for your module. If a location is specified, SOMETHING will appear there, even if you don’t have a getDom() routine.

                                You can’t make changes to another module’s Dom object, but you can hide or show it. However, you can’t do that until that Dom object is initially created.

                                When all the Dom objects for all modules have been created at startup, MagicMirror dispatches the DOM_OBJECTS_CREATED notification. By waiting for this notification, you can be sure that any module you attempt to hide will be hidden.

                                1 Reply Last reply Reply Quote 0
                                • S Offline
                                  sharmmoh1983
                                  last edited by

                                  @j-e-f-f It is kind of working now… I will test it thoroughly for two days and will revert in case of any issue

                                  @j-e-f-f @Sean thank a lot for your prompt replies and efforts

                                  1 Reply Last reply Reply Quote 0

                                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                  With your input, this post could be even better 💗

                                  Register Login
                                  • 1
                                  • 2
                                  • 1 / 2
                                  • First post
                                    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