<?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[How to show&#x2F;hide a module depending on if has data]]></title><description><![CDATA[<p dir="auto">I have a custom module which  displays a json list and is working fine.   It uses node_help.js to fetch the json from a server.</p>
<p dir="auto">I would like to hide the module, header and all, if there is no data available.   I’ve tried adding show() and hide() in the socketNotifcationReceived() :</p>
<blockquote>
<p dir="auto">If (items.length&gt; 0) {<br />
this.show();<br />
this.updateDom(animationSpeed);<br />
} else {<br />
this.hide();<br />
this.updateDom(animationSpeed);<br />
}</p>
</blockquote>
<p dir="auto">The module will appear if there is initially items in the list.  If I remove all items from the list,  the module will “hide”.  But if I add items to the server where the json is pulled, the module will not reappear.</p>
<p dir="auto">I’m guessing I don’t understand what all hide() does?</p>
<p dir="auto">Thank you for any guidance.</p>
]]></description><link>https://forum.magicmirror.builders/topic/19158/how-to-show-hide-a-module-depending-on-if-has-data</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 11:16:06 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/19158.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Nov 2024 21:49:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to show&#x2F;hide a module depending on if has data on Thu, 21 Nov 2024 20:41:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a>  Thank you! Using developers tab and console.logs,  I fixed the data coming in  (driven on a timer).   Once that was correct, your confirmation/explanation of show/hide made total sense!</p>
<blockquote>
<p dir="auto">If (items.length&gt; 0) {<br />
this.show();<br />
} else {<br />
this.hide();<br />
}</p>
</blockquote>
<p dir="auto">Works great!</p>
]]></description><link>https://forum.magicmirror.builders/post/121504</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/121504</guid><dc:creator><![CDATA[shicks]]></dc:creator><pubDate>Thu, 21 Nov 2024 20:41:37 GMT</pubDate></item><item><title><![CDATA[Reply to How to show&#x2F;hide a module depending on if has data on Wed, 20 Nov 2024 22:11:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/shicks" aria-label="Profile: shicks">@<bdi>shicks</bdi></a> 1st you don’t need the updateDom() calls… show will trigger that<br />
hide will not, because well, there is nothing to show, so no point updating</p>
<p dir="auto">now… what drives your socketNotification?  (node_helper  on a timer, or node_helper in response to module sendSocketNotification, driven on a timer)</p>
<p dir="auto">have you verified that the notification has arrived?</p>
<p dir="auto">if you use the developers window sources tab, you can put a breakpoint stop on the 1st executable line after it so see if it is called…</p>
<p dir="auto">I don’t see anything wrong with the objective</p>
]]></description><link>https://forum.magicmirror.builders/post/121483</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/121483</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 20 Nov 2024 22:11:23 GMT</pubDate></item></channel></rss>