Logic Machine Forum
Diasble buttons - 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: Diasble buttons (/showthread.php?tid=5983)



Diasble buttons - ceddix - 05.05.2025

Hi, 

Tried to use Button diasble with custom java script.

This is the script I use,

Code:
$(function(){
 
  var ObjectAddress = Scada.encodeGroupAddress('1/0/10'); // Use 1 bit object !
  objectStore.addListener(ObjectAddress, function(obj, type) {
   
     if ( obj.value == true ) {
        $(".disabledbyknx").css("opacity", 0.5);
        $(".disabledbyknx").css("pointer-events", 'none');
     } else {
        $(".disabledbyknx").css("opacity", 1);
        $(".disabledbyknx").css("pointer-events", 'all');
     }

  });
 
});

It doesnt do anything with the buttons. 

I tried in a another logic machine, and it worked there. 

Is there any solutions why it maybe doesnt work?


RE: Diasble buttons, - Erwin van der Zwart - 06.05.2025

Did you add a additional class -> disabledbyknx to all the elements on the visu that you want to disable and reloaded the visu?


RE: Diasble buttons, - ceddix - 06.05.2025

Yes, several times!

It works in another logic machine. 

And the diasble object its 1bit and so on.


RE: Diasble buttons, - Erwin van der Zwart - 06.05.2025

Can you try the grp.listen method? Just tried this on the latest FW and works for me..

Code:
$(function(){
  if (typeof grp != 'undefined') {
    grp.listen('1/0/10', function(object, state) {
      if (state == 'value') {
       if (object.value == true) {
        $(".disabledbyknx").css("opacity", 0.5);
        $(".disabledbyknx").css("pointer-events", 'none');
       } else {
        $(".disabledbyknx").css("opacity", 1);
        $(".disabledbyknx").css("pointer-events", 'all');
       }
      }
    }, true);
  } 
});



RE: Diasble buttons, - ceddix - 06.05.2025

I've tried the longpress java script also in that logic machine, it doesent work either. 

Then I've tried that script in another logic machine, and that works perfect. 
Is there maybe something with the custom javascript that isnt enabled in that logic machine that doesent work?
Can't find any differences between the logic machines...


RE: Diasble buttons, - Erwin van der Zwart - 06.05.2025

Do you see errors in the browser console (F12)? Do you run same FW version in both controllers?


RE: Diasble buttons, - Daniel - 06.05.2025

Is the firmware the same on both LMs?


RE: Diasble buttons, - ceddix - 06.05.2025

Yes,

both have
"HW: LM5 Lite (i.MX6)
SW: 20240426"

I have error in the console "Uncaught SyntaxError: Unexpected end of input"

What can that means?

Just googled the error and the first answer was put another }); in the end.

Its working now,
Thanks!