This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Visibility or active/clickable by object status value
#1
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
Don't ask what we can do in KNX but wonder what we can't - www.KNXlogic.eu
Reply
#2
You have a syntax error, it should be:
Code:
$(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', value ? 'visible' : 'hidden');
      });
    }
  });
});
Reply
#3
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
Don't ask what we can do in KNX but wonder what we can't - www.KNXlogic.eu
Reply
#4
Listener is attached to the main (control) object. Change 'object' to 'status-object' on line 3 to listen to the status object instead.
Reply
#5
(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
Don't ask what we can do in KNX but wonder what we can't - www.KNXlogic.eu
Reply


Forum Jump: