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.

    Unable to click a toggle button

    Scheduled Pinned Locked Moved Troubleshooting
    22 Posts 4 Posters 15.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.
    • strawberry 3.141S Offline
      strawberry 3.141 Project Sponsor Module Developer @shre28491193
      last edited by

      @shre28491193

      Your problem is that you add the click event after the dom is ready event is fired, but this will never happen, because you add this line after the event already happend, so you don’t add the click event ever.

      replace

      $(document).ready(function(){
                      $("a").click(function(){
      			debugger;
      	    		Log.info('mouse-click-event');
                  		$(this).toggleClass('off');
              	});
      	});
      

      with

      regenToggle.addEventListener('click', () => {
          Log.info('mouse-click-event');
          regenToggle.classList.toggle("off");
      });
      

      then you add the click event immediately to your anchor tag, also you don’t need jquery any longer and so you can remove

          getScripts: function(){
              return ["jquery.js" , "jquery-ui.min.js"];
          },
      

      in the css you have the problem that you set the width of the class hvac to 0px, thats why you will not see the toggle button. change this to a value like in the jsfiddle example.

      Furthermore you have a lot of redundant unused variables in your code, but I guess you will use them when you continue with your module. I hope that gives you a little starting boost.

      Please create a github issue if you need help, so I can keep track

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

        @strawberry-3-141

        Thanks for your suggestion. I replaced the snippet for click part of it.

        regenToggle.addEventListener(‘click’, () => { - I presume this was meant to be ‘regenToggle.addEventListener(“click” , function() {’

        also I changed the width of the HVAC CSS element. I still see the same issue - yet to debug more.

        strawberry 3.141S 1 Reply Last reply Reply Quote 0
        • strawberry 3.141S Offline
          strawberry 3.141 Project Sponsor Module Developer @shre28491193
          last edited by

          @shre28491193 do you get any error messages in the electron console?

          Please create a github issue if you need help, so I can keep track

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

            @strawberry-3-141 - Sorry, I am not sure how to access the electron console. Could you direct me to it ?

            strawberry 3.141S 1 Reply Last reply Reply Quote 0
            • strawberry 3.141S Offline
              strawberry 3.141 Project Sponsor Module Developer @shre28491193
              last edited by

              @shre28491193 press ctrl+shift+i

              Please create a github issue if you need help, so I can keep track

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

                Got it. Will try this in a few minutes. I am in a meeting at work now.

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

                  @strawberry-3-141 No errors in the console. :-(

                  strawberry 3.141S 1 Reply Last reply Reply Quote 0
                  • strawberry 3.141S Offline
                    strawberry 3.141 Project Sponsor Module Developer @shre28491193
                    last edited by

                    @shre28491193 so you can see the button, but after a click nothing happens?

                    Please create a github issue if you need help, so I can keep track

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

                      Button shows up on the mirror , but still click event doesnt work.

                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        shre28491193 @strawberry 3.141
                        last edited by

                        @strawberry-3.141 Button shows up on the mirror , but still click event doesnt work

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