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.

Make Button visible/invisible
#18
(06.06.2018, 06:32)admin Wrote: This might happen if object element is rendered after hide is called.

One possible solution is to add class to body element instead. Then the browser will handle the rest Smile

Custom CSS:
Code:
body.hidebyknx .hidebyknx {
  display: none !important;
}

Custom JavaScript:
Code:
$(function(){
  grp.listen("1/1/1", function(object) {
    $(document.body).toggleClass("hidebyknx", object.value == false);
  });
});

I am using a function
Code:
$(function(){
  for (let i = 1; i <= 13; i++) {
    const selector = `.hide${i}`;
    grp.listen(`35/0/${i}`, function(object, state) {
      if (state === 'value') {
        $(selector).toggleClass("hide", object.value);
      }
    }, true); // set to true to respond on the same value
  }
});
to handle the hide/unhide of several objects  in two diffent pages. I noticed the same problem about the state of objects and I fixed it with a periodic reading. But I would avoid that. So how I could use your body element solution?

Thanks

Peppe
Reply


Messages In This Thread
Make Button visible/invisible - by forsterm - 27.03.2017, 16:29
RE: Make Button visible/invisible - by cekca - 28.03.2017, 16:49
RE: Make Button visible/invisible - by JMM - 06.06.2018, 06:17
RE: Make Button visible/invisible - by admin - 06.06.2018, 06:32
RE: Make Button visible/invisible - by gdimaria - 24.10.2023, 06:48
RE: Make Button visible/invisible - by admin - 09.04.2019, 07:46
RE: Make Button visible/invisible - by Fahd - 07.02.2023, 07:56
RE: Make Button visible/invisible - by admin - 07.02.2023, 09:13

Forum Jump: