Read the statement by Michael Teeuw here.
How to show/hide a module depending on if has data
-
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.
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() :
If (items.length> 0) {
this.show();
this.updateDom(animationSpeed);
} else {
this.hide();
this.updateDom(animationSpeed);
}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.
I’m guessing I don’t understand what all hide() does?
Thank you for any guidance.
-
@shicks 1st you don’t need the updateDom() calls… show will trigger that
hide will not, because well, there is nothing to show, so no point updatingnow… what drives your socketNotification? (node_helper on a timer, or node_helper in response to module sendSocketNotification, driven on a timer)
have you verified that the notification has arrived?
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…
I don’t see anything wrong with the objective