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.

Change attribute in visu following a knx object
#1
I have been asked to make some elements of the visualization "read-only" if a specified KNX object is off. Is there a way I can do this?
Reply
#2
See this: https://forum.logicmachine.net/showthrea...9&pid=8921
Reply
#3
Okay, I saw the example. I am trying to make it work, but I need to know if it is possible to use more than one "additional class" per object since I already have a generic class handling the animations of all the buttons, and I need this to happen to just a bunch of those.
Reply
#4
You can set any number of additional classes, separated by space.
Reply
#5
Does not seem to be working, I probably got something wrong 

I pasted this in in my javascript custom:
Code:
$(function() {
  if (typeof grp != 'object') {
    return;
  }

  grp.listen('32/1/22', function(object, state) {
    $('.dis_da_totale').toggleClass('el-disabled', object.value == false);
  });
});
 
pasted this in Custom CSS:
Code:
.el-disabled {
  opacity: 0.5;
}
.el-disabled,
.el-disabled * {
  pointer-events: none !important;
}

and I used dis_da_totale as an additional class for the button is that correct, or am I missing something?
Reply
#6
Your example works fine for me. Use browser dev tools (F12) to check if the element has a specific class.
Reply
#7
Maybe then I did not understand what i supposed to do. Like I expected the button to stop working as long as the value of "32/1/22" is false. Is this correct?
Reply
#8
(27.08.2024, 11:59)admin Wrote: Your example works fine for me. Use browser dev tools (F12) to check if the element has a specific class.

I think he did not also add the class el-disabled to the additonal classes so the CSS does not apply to the element because of the class dis_da_totale is used, so intthis case the additional class needs to hold both dis_da_totale el-disabled or am i wrong?
Reply
#9
(27.08.2024, 14:11)Erwin van der Zwart Wrote:
(27.08.2024, 11:59)admin Wrote: Your example works fine for me. Use browser dev tools (F12) to check if the element has a specific class.

I think he did not also add the class el-disabled to the additonal classes so the CSS does not apply to the element because of the class dis_da_totale is used, so intthis case the additional class needs to hold both dis_da_totale el-disabled or am i wrong?

I just tried that but it makes the element disabled no matter what the value is.

I forgot to say that I checked with dev tools and the element seems to have the "dis_da_totale" class
Reply
#10
Post a screenshot of the relevant visualization element settings.
Reply
#11
(27.08.2024, 14:24)admin Wrote: Post a screenshot of the relevant visualization element settings.

I have attached two screenshots: the settings and the actual visu.  "uso TOTALE OFF" is the object which should lock the buttons below

Attached Files Thumbnail(s)
       
Reply
#12
Send your backup via PM. Use WeTransfer or another similar service.
Reply
#13
(28.08.2024, 13:58)admin Wrote: Send your backup via PM. Use WeTransfer or another similar service.

Here you go: https://we.tl/...
Reply
#14
It's not working because the previous function in Custom JavaScript fails with an error. Change it to this and it will work:
Code:
$(function(){
  $('.slider-alt').each(function(_, el) {
    var $el = $(el), addr = $el.data('object'), icon = $el.find('.icon');
    if (addr) {
      grp.listen(addr, function(obj) {
        var val = obj.value || false;
        //val = Math.round(2.55 * (100 - val));
        var name = el.getAttribute('data-object-name');
        el.textContent = name
      });
    }
  });
});
Reply
#15
(29.08.2024, 15:49)admin Wrote: It's not working because the previous function in Custom JavaScript fails with an error. Change it to this and it will work:
Code:
$(function(){
  $('.slider-alt').each(function(_, el) {
    var $el = $(el), addr = $el.data('object'), icon = $el.find('.icon');
    if (addr) {
      grp.listen(addr, function(obj) {
        var val = obj.value || false;
        //val = Math.round(2.55 * (100 - val));
        var name = el.getAttribute('data-object-name');
        el.textContent = name
      });
    }
  });
});

Thanks, admin. Problem solved as always Big Grin
Reply


Forum Jump: