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.

    Firing off Javascript after getDom elements have drawn on the page

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    2 Posts 2 Posters 1.0k 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.
    • J Offline
      jetnet
      last edited by

      I am using Magic Mirror with bootstrap, jquery, and some custom javascript code to make touchscreen things happen on a module I am working on. If I fire off the javascript init function after the updateDom event, I don’t get an error, but the dom elements I am trying to run my function against are not yet part of the page, so nothing happens. As part of the debug process, I put a console log line in, so I can confirm that the javascript init() function ran. The module displays everything correctly, but the touch screen elements do not work.

      The module functions a lot like the newsfeed, so after 15 seconds, it calls back out to the server for a new update. If I don’t send it a new update (so it doesn’t redraw the html) but the javascript init fires again, now all of the touch screen elements work.

      Basically what I need to know is: where do I need to put the init() function call, in order to let all the dom elements draw on the page, so the javascript can see them? Is there an “afterGetDom” function I can run?

      I know i am not submitting the code along with this question, but the code is fairly length, and I didn’t want to paste it. If you guys need to see it, I can provide chunks of it.

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

        @jetnet the only hook that I’m aware off is when the getdom function gets executed the first time, then you could work with MODULE_DOM_CREATED or DOM_OBJECTS_CREATED, but for me it sounds like you are looking for something that gets triggered everytime the dom gets updated not just once.

        https://github.com/MichMich/MagicMirror/tree/master/modules#notificationreceivednotification-payload-sender

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

        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 / 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