24.10.2023, 06:48
(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
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
}
});
Thanks
Peppe