Read the statement by Michael Teeuw here.
Gurus, what is the problem with this code ?
-
When I use this function I got an error and nothing appear on the screen.
/* Magic Mirror Config Sample * * By Michael Teeuw http://michaelteeuw.nl * MIT Licensed. * * For more information how you can configurate this file * See https://github.com/MichMich/MagicMirror#configuration * */ var full = ""; function LoadData() { full = "Hello"; } $( document ).ready(function() { LoadData(); }); var config = { address: "localhost", port: 8080, ipWhitelist: ["192.168.1.9"], language: "en", timeFormat: 24, units: "metric", zoom: 0.85, modules: [ { module: "helloworld", position: "center", config: { text: full } }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;}
-
@rsellmer
We don’t knowwhat problem
do you have. How can we imagine? -
What are you trying to do and what isn’t working?
-
I can’t read it when it’s not in a code block? :-0)
-
Ok … I am so sorry about that. It was not easy to understand.
Let me try to explain … I need call a function which is declared into the config.js. However, this is impossible. Nothing appeared on the screen. I did not find any example using a function call. Is it clear ? -
/* Magic Mirror Config Sample * * By Michael Teeuw http://michaelteeuw.nl * MIT Licensed. * * For more information how you can configurate this file * See https://github.com/MichMich/MagicMirror#configuration * */ var full = ""; function LoadData() { full = "Hello"; } $( document ).ready(function() { LoadData(); }); var config = { address: "localhost", port: 8080, ipWhitelist: ["192.168.1.9"], language: "en", timeFormat: 24, units: "metric", zoom: 0.85, modules: [ { module: "helloworld", position: "center", config: { text: full } }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;}
-
@rsellmer
As I’ve written in your other post, jQuery is not included as a default. You did a try to use jQuery($(document).ready()
) -
@sean Tks again … I am newb with MM, so I think that it is not possible to create a function in the config.js … I think that this will not work. because the next step I will need to call an api from config.js to get some data from mysql.
In my test using a config.js out the MM system, I could call the api, but I think that this is not possible in the MM. Am I right ? Tks -
@rsellmer
config.js
is not for your custom job. leave it.
When you want to do something your own, createmodule
.
Read the manual.And see how other modules work;
You can start by modifying any simple module as your wish.
-
@rsellmer
one more thing;
config.js
is validated when MM is booted up, not rendered. maybe you can put some codes inconfig.js
but that would not be working as your expectation.