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.

    jquery module not working --- need help!

    Scheduled Pinned Locked Moved Troubleshooting
    10 Posts 3 Posters 2.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 @justjim1220
      last edited by sdetweil

      @justjim1220 we discussed this offline…

      the jquery code is executing inline of the getDom() function, and the element selectors

      $('#more')  is same as  (document.getElementById('more')) 
      

      will fail as the content is not IN the html document yet

      Sam

      How to add modules

      learning how to use browser developers window for css changes

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

        MagicMirror is what is called a Single Page web application. one html page.

        the base framework defines the page layout and regions. each module can contribute ITS little piece of content by returning the top element of that content starting with a div.

        the getDom module function is responsible for developing and returning that div tree.

        sometime AFTER the getdom function returns with the div object

        var wrapper=  document.createElement('div')
        return wrapper
        

        the div will be inserted into the dom at the module defined location. (position)
        note that multiple modules may contribute to the same location, in a FIFO order. (as defined in config.js)
        element.appendChild(new_content_anchor)

        any code inside getDom() that attempts to locate elements by ID (search the single page dom) will FAIL,
        as the modules dom contribution has not been inserted until AFTER sometime getdom() returns the div element

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • cowboysdudeC Offline
          cowboysdude Module Developer
          last edited by cowboysdude

          You can’t just go copy something and plug it in… you have to have an understanding of how it works… @sdetweil gave a REALLY great explanation.

          You can load your jquery either with the above getScripts or you can do in the getDom … I have a few things working with jQuery… go look at my MMM-Recipe module…for an example of how I did it.

          justjim1220J 3 Replies Last reply Reply Quote 0
          • justjim1220J Offline
            justjim1220 Module Developer @cowboysdude
            last edited by

            @cowboysdude Thanks! I will do that! :winking_face:

            "Life's Too Short To Dance With Ugly People"
            Jim Hallock - 1995

            1 Reply Last reply Reply Quote 0
            • justjim1220J Offline
              justjim1220 Module Developer @cowboysdude
              last edited by

              @cowboysdude How do I mark this as SOLVED?

              "Life's Too Short To Dance With Ugly People"
              Jim Hallock - 1995

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

                @justjim1220 I’d like to see what you did.

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                justjim1220J 1 Reply Last reply Reply Quote 0
                • justjim1220J Offline
                  justjim1220 Module Developer @sdetweil
                  last edited by

                  @sdetweil
                  LOL!
                  I merged a pull request from @Seann :face_with_tears_of_joy:
                  I am going through it right now to see what he did.
                  And, I am going through the changes you made with the VideoPlayer2 module.

                  With what you have taught me and with the changes to the Video Player and the Kitchen timer,
                  I am gonna try to apply this to a few other programs I have ready to convert from JQuery.

                  I am also going through @cowboysdude’s Recipe module to see how to get JQuery to actually work with MM.

                  Today, I am spending time RE-LEARNING javascript and how to apply it to MM modules. :upside-down_face: :upside-down_face: :upside-down_face:

                  Maybe it will steer me away from JQuery in the future! :winking_face:

                  "Life's Too Short To Dance With Ugly People"
                  Jim Hallock - 1995

                  S 1 Reply Last reply Reply Quote 0
                  • justjim1220J Offline
                    justjim1220 Module Developer @cowboysdude
                    last edited by

                    @cowboysdude
                    I really like the changes you’ve made with this Recipe Module!!! :winking_face:

                    "Life's Too Short To Dance With Ugly People"
                    Jim Hallock - 1995

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

                      @justjim1220 yeh, his use of jQuery is not against the HTML as u were doing, but against data items returned from other sources.

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      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 Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy