Visibility or active/clickable by object status value - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9) +--- Thread: Visibility or active/clickable by object status value (/showthread.php?tid=4050) |
Visibility or active/clickable by object status value - cdebackere - 20.05.2022 Is try to active/show and desactivare/hide a command button icon on the basis of the status object value. Ideally, the element is always visible (adding an On, active icon and an Off, passive/greyed icon), but only can be selected/activated/clicked when value of status object is true I added JS, but doesn't seem to do the trick $(function() { $('.hidden-by-value').each(function(_, el) { var addr = $(el).data('object'); if (addr) { grp.listen(addr, function(obj) { var value = obj.value; $(el).css('visibility', if value {'visible'} else {'hidden'}); }); } }); }); Do I overlook something? is 'object' correct? Or is this the main abject, and not the status object? Thx RE: Visibility or active/clickable by object status value - admin - 20.05.2022 You have a syntax error, it should be: Code: $(function() { RE: Visibility or active/clickable by object status value - cdebackere - 20.05.2022 Thx for that It's still not working correctly. In the inspector now the 'visibility' tag is indeed there. But the visibility doesn't update when a new value/telegram appears on the sts group object. I added a console.log(value), and only one value is logged: at page load, not when the status object value changes RE: Visibility or active/clickable by object status value - admin - 20.05.2022 Listener is attached to the main (control) object. Change 'object' to 'status-object' on line 3 to listen to the status object instead. RE: Visibility or active/clickable by object status value - cdebackere - 20.05.2022 (20.05.2022, 15:07)admin Wrote: Listener is attached to the main (control) object. Change 'object' to 'status-object' on line 3 to listen to the status object instead. that's exacctly what I just noticed: the addr is the main object not the status object. works like a charm now. Thx admin, and have a nice weekend |