<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[wrapper.innerHTML]]></title><description><![CDATA[<p dir="auto">wrapper.innerHTML = “”<br />
Is this code available only in getDom?<br />
I want to use this in other functions.</p>
<p dir="auto">For example, start: function()</p>
]]></description><link>https://forum.magicmirror.builders/topic/6083/wrapper-innerhtml</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 06:21:01 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/6083.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Jan 2018 03:04:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to wrapper.innerHTML on Sun, 07 Jan 2018 00:02:29 GMT]]></title><description><![CDATA[<p dir="auto">I was interrupted when I wrote my answer and forgot to add what I was initially going to say. I decided to write a new reply instead of editing the above, not to confuse anyone and keep the two apart.</p>
<p dir="auto">There is another way to update the content of an element (that <em>has</em> been created in <em>getDom</em> before):</p>
<p dir="auto"><strong>Example 3, .innerHTML:</strong></p>
<pre><code>start: function() {
// stays the same as above
    setTimeout(function() {
        this.magicContent(self);  // this will call the function "magicContent"
    }, 10 * 1000);                // 10 seconds after the start, 5 seconds after "buildContent"
},
// we don't touch getDom or buildContent!
magicContent: function() {
    document.getElementById("my-content").innerHTML = "Changed &lt;i&gt;&lt;b&gt;yet again!";
}
</code></pre>
<p dir="auto"><em>document.getElementById(“my-content”).innerHTML = “content”;</em> will update the selected element (the div with the id “my-content”) with the selected content <strong>without</strong> having to call <em>updateDom()</em>.</p>
<p dir="auto">Keep in mind that this will only work on elements that were created before in <em>getDom</em>, so it will not work within <em>start: function()</em> …</p>
<p dir="auto"><strong>Caution!</strong> This can also update elements of other modules, so be careful and use unique IDs.</p>
]]></description><link>https://forum.magicmirror.builders/post/33481</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/33481</guid><dc:creator><![CDATA[doubleT]]></dc:creator><pubDate>Sun, 07 Jan 2018 00:02:29 GMT</pubDate></item><item><title><![CDATA[Reply to wrapper.innerHTML on Sat, 06 Jan 2018 15:43:59 GMT]]></title><description><![CDATA[<p dir="auto">In this context, yes.</p>
<p dir="auto"><em>“wrapper”</em> is just a variable that holds the content of the (new) HTML element that you create there and <em>“getDom”</em> grabs the content that is to be put into the DOM (Document Object Model, the raw content/structure), =&gt; rendered.</p>
<p dir="auto"><strong>Example 1, basic:</strong></p>
<pre><code>getDom: function() {
    var wrapper = document.createElement("div");
    wrapper.setAttribute"id", "my-content");
//  It's always a good idea to make an element addressable
    wrapper.innerHTML = "Hello World!";
    return wrapper;
}
</code></pre>
<p dir="auto">getDom is called upon starting, grabbing the elements and putting them in place and if you want to change something later on, you need to call <em>“this.updateDom()”</em> to render it again with the new content.</p>
<p dir="auto"><strong>Example 2, updating:</strong></p>
<pre><code>start: function() {
    var self = this;
    Log.info("Starting module: " + this.name);
    this.myContent = "nothing yet"; // global variable, available to all functions
    setTimeout(function() {
        this.buildContent(self);  // this will call the function "buildContent"
    }, 5 * 1000);                 // 5 seconds after the start (5 * 1000 ms)
},
getDom: function() {
    var wrapper = document.createElement("div");
    wrapper.setAttribute"id", "my-content");
    wrapper.innerHTML = this.myContent ; // will show "nothing yet" at the beginning
    return wrapper;
},
buildContent: function(self) { // see above, this will be started after 5 seconds
//  do your content building
    this.myContent = "New content!"; // changes the value of the global variable
    self.updateDom(); // call for the DOM to be updated, thus showing the new content
}
</code></pre>
<p dir="auto">I hope that’s somewhat understandable.</p>
]]></description><link>https://forum.magicmirror.builders/post/33443</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/33443</guid><dc:creator><![CDATA[doubleT]]></dc:creator><pubDate>Sat, 06 Jan 2018 15:43:59 GMT</pubDate></item><item><title><![CDATA[Reply to wrapper.innerHTML on Sat, 06 Jan 2018 15:07:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/adadws" aria-label="Profile: adadws">@<bdi>adadws</bdi></a> in the start function your module is not rendered yet. so it doesnt exist, if your trying for module specific stuff, but it would exist for elements like the body</p>
]]></description><link>https://forum.magicmirror.builders/post/33440</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/33440</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sat, 06 Jan 2018 15:07:08 GMT</pubDate></item></channel></rss>