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() blocks MagicMirror

    Scheduled Pinned Locked Moved Development
    28 Posts 2 Posters 6.7k Views 2 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.
    • 1 Offline
      1BlauNitrox @sdetweil
      last edited by

      @sdetweil I changed getDom() to this:

      getDom: function() {
              const wrapper = document.createElement("div");
              if(response.lenght <= 0) {
                  wrapper.innerHTML = "No Entries";
              } else {
                  wrapper.innerHTML = this.response;
              }
              return wrapper;
      	},
      

      There is a check if the array has any entries.

      But the mirror shows “undefined”

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

        @1blaunitrox said in updateDom() blocks MagicMirror:

        if(response.lenght <= 0) {

        this.response.length

        always gotta use this.

        unless u created the variable INSIDE the routine using it…

        use the debugger

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 1 Reply Last reply Reply Quote 0
        • 1 Offline
          1BlauNitrox @sdetweil
          last edited by 1BlauNitrox

          @sdetweil
          response.PNG

          Not exectly what I wanted :joy:
          Why can getDom() not transfrom the array in a readable string?

          S 2 Replies Last reply Reply Quote 0
          • S Offline
            sdetweil @1BlauNitrox
            last edited by

            @1blaunitrox yes, this.response is an object

                    this.response = {
                        "name": "Test",
                        "entries": {
                            "lessions": "Teacher Subject Room representation"
                        }
                    };
            

            html doesn’t know objects

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 1 Reply Last reply Reply Quote 0
            • 1 Offline
              1BlauNitrox @sdetweil
              last edited by

              @sdetweil Is there a Json parser I can use?

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

                @1blaunitrox said in updateDom() blocks MagicMirror:

                Why can getDom() not transfrom the array in a readable string?

                getDom() CAN do anythign YOU implement… it does NOTHING by itself…

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                S 1 2 Replies Last reply Reply Quote 0
                • S Offline
                  sdetweil @sdetweil
                  last edited by

                  @sdetweil JSON.parse, JSON. stringify

                  u have an object so, stringify turns it into text
                  parse takes text and makes an object

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • 1 Offline
                    1BlauNitrox @sdetweil
                    last edited by

                    @sdetweil What about JSON.stringify(this.response);

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

                      @1blaunitrox that would work

                      but it will be the JSON text representation of the object

                      all fields and values

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 1 Reply Last reply Reply Quote 0
                      • 1 Offline
                        1BlauNitrox @sdetweil
                        last edited by

                        @sdetweil
                        First: Is there an other option?

                        Second: I added the getData() function in getDom()

                                const wrapper = document.createElement("div");
                                this.getData();
                                if(this.response.lenght <= 0) {
                                    wrapper.innerHTML = "No Entries";
                                } else {
                                    wrapper.innerHTML = JSON.stringify(this.response);
                                }
                                return wrapper;
                        

                        Now the mirror show UNDEFINED again

                        S 2 Replies Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 1 / 3
                        • 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