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

jquery module not working --- need help!

Scheduled Pinned Locked Moved Troubleshooting
10 Posts 3 Posters 2.2k 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.
  • J Offline
    justjim1220 Module Developer
    last edited by Feb 6, 2019, 4:10 AM

    Ok, so I wrote this program: https://codepen.io/justjim1220/pen/dapLPo?editors=1000

    And in CodePen, it works perfectly.

    But I have attempted to convert it over to be a MagicMirror module:

    https://github.com/justjim1220/MMM-KitchenTimer

    it shows up exactly as it should, BUT, none of the buttons work.
    I get the hover action, and even the click action, but the buttons don’t do anything else.
    Plus, I don’t get any errors in dev console.

    Any ideas?

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

    S 1 Reply Last reply Feb 6, 2019, 4:39 AM Reply Quote 0
    • S Away
      sdetweil @justjim1220
      last edited by sdetweil Feb 6, 2019, 4:41 AM Feb 6, 2019, 4:39 AM

      @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 Away
        sdetweil
        last edited by Feb 6, 2019, 4:55 AM

        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
        • C Offline
          cowboysdude Module Developer
          last edited by cowboysdude Feb 6, 2019, 10:20 PM Feb 6, 2019, 10:19 PM

          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.

          J 3 Replies Last reply Feb 6, 2019, 10:20 PM Reply Quote 0
          • J Offline
            justjim1220 Module Developer @cowboysdude
            last edited by Feb 6, 2019, 10:20 PM

            @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
            • J Offline
              justjim1220 Module Developer @cowboysdude
              last edited by Feb 6, 2019, 10:23 PM

              @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 Feb 6, 2019, 10:29 PM Reply Quote 0
              • S Away
                sdetweil @justjim1220
                last edited by Feb 6, 2019, 10:29 PM

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

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                J 1 Reply Last reply Feb 6, 2019, 10:36 PM Reply Quote 0
                • J Offline
                  justjim1220 Module Developer @sdetweil
                  last edited by Feb 6, 2019, 10:36 PM

                  @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 Feb 7, 2019, 1:13 AM Reply Quote 0
                  • J Offline
                    justjim1220 Module Developer @cowboysdude
                    last edited by Feb 6, 2019, 11:33 PM

                    @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 Away
                      sdetweil @justjim1220
                      last edited by Feb 7, 2019, 1:13 AM

                      @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
                      1 / 1
                      • First post
                        1/10
                        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