MagicMirror² v2.14.0 is available! For more information about this release, check out this topic.

Adding a jQuery Module

  • Hi Guys,
    I played around with building a module by myself and I got some questions.
    I have to say my knowledge in Vanilla JS is somewhat limited, so I turned to jQuery.

    I was able to including jQuery, and any script and CSS for that matter, But I was not able to “Init” it.
    Is there a place I can call “document ready” ? tried in the getDOM method and any other “build in” method and couldn’t get it to init.

    The other thing that was bothering me is not being able to debug properly, i’m working via SSH.
    where can I see logs, or better yet console.log() or “debugger;” ?

    I am also not sure what “browser” is being used, I don’t think CSS3 stuff is working.

    Thanks !

  • Project Sponsor Module Developer

    @NiviJah i think the document ready is fired before the modules are loaded (didn’t test it) there is a broadcast of the core called DOM_OBJECTS_CREATED

    if you’re using console.log or it will be in the electron console, you can see the console by starting the mirror via npm start dev

    electron is based on chromium prefix would be -webkit

    If you tell for what you want to use jquery, we can help you to do it in vanilla javascript

  • Moderator

    In addition to @strawberry-3.141 response. I wanted to chime in with option of running it locally on your dev machine and using node serveronly and pointing your browser at http://localhost:8080 using familiar tools while developing. One of the catches is it will not work well if you are developing module that needs to interact with GPIO or other proprietary RasPi functionality.

    My personal workflow is roughly outlined here:

  • Thank you,
    This is very helpful.
    If I understand correctly, do I need to use DOM_OBJECTS_CREATED like this ?

    notificationReceived: function(notification, payload, sender){
    	if (notification === 'DOM_OBJECTS_CREATED'){

    Does that go into my plugin file ? (i.e not the node helper)

  • Project Sponsor Module Developer

    @NiviJah your Code example is correct, except that you don’t Need the ready function, at this Point the Dom is ready and you can do whatever You Wanted to without wrapping it into another event

  • jQuery didn’t want to play nice, i don’t know why, so I had to work with Vanilla JS.

    here is the result


  • @NiviJah Did you get jQuery to run at all?

Log in to reply