Logic Machine Forum
JS to detect edition of a string - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: JS to detect edition of a string (/showthread.php?tid=3002)



JS to detect edition of a string - SigmaTec - 23.11.2020

Hi all,

in a JS script, I know how to detect the state of a Bool object, as

Code:
$(function(){
 
  // managing widget-20
 
  // open widget
  grp.listen('33/1/7', function(object, state) {
    if (state == 'value' && object.value == "1" ) {
        // Command to show widget
        $("#widget-20").removeClass("hide");
    }
  }, true); // set to true to execute on same object value

});


but how to detect that a String object has just been clicked (for example for modification by the user)?

Goog week !


RE: JS to detect edition of a string - Erwin van der Zwart - 23.11.2020

Try this:
Code:
$(function(){
  grp.listen('32/1/18', function(object, state) {
    if(state == 'init'){
      var lastvalue = object.value;
    } else {
      if (lastvalue != object.value){
        console.log('value is changed');
        // Do here other actions
        lastvalue = object.value;
      }
    }
  }, true); // set to true to execute on same object value
});



RE: JS to detect edition of a string - SigmaTec - 24.11.2020

Perfect , as usual Erwin !
Thank's