Logic Machine Forum
HTML Code to get the data-object an data-object-name - 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: HTML Code to get the data-object an data-object-name (/showthread.php?tid=5887)



HTML Code to get the data-object an data-object-name - giel.velghe - 13.02.2025

Hello,

Is there e way to get the data-object (for example group adress 1/1/6) and the data-object-name once a button is pushed?

I have a user/customapp.lp with html code and want to extract this data of once a button is pushed (so there will be multiple on the visu).
Kind Regards
Giel

picture: https://ibb.co/ccRM9rQK


RE: HTML Code to get the data-object an data-object-name - admin - 13.02.2025

Add an Additional class (my-element) to the element then add this to Custom JavaScript.
Code:
$(function(){
  $('.my-element').click(function() {
    var data = this.dataset;
    var message = {
        object: data.object,
      objectName: data.objectName,
    }
    
    window.parent.postMessage(message);
  });
});

In .lp document which includes the visualization via iframe use this code to get the message:
Code:
window.addEventListener('message', function(event) {
  console.log('event data', event.data)
}, false);



RE: HTML Code to get the data-object an data-object-name - Fistel - 13.02.2025

Morning everybody

I'm a beginner on wiser for knx. I want to read data sent from smartmeter and then send instructions to an actuator depending on what i received from smartmeter


RE: HTML Code to get the data-object an data-object-name - Daniel - 13.02.2025

(13.02.2025, 09:02)Fistel Wrote: Morning everybody

I'm a beginner on wiser for knx. I want to read data sent from smartmeter and then send instructions to an actuator depending on what i received from smartmeter

Create a new thread and describe with more details what meter is it and what interface it has.
This topic is about something totally different.


RE: HTML Code to get the data-object an data-object-name - giel.velghe - 13.02.2025

(13.02.2025, 08:55)admin Wrote: Add an Additional class (my-element) to the element then add this to Custom JavaScript.
Code:
$(function(){
  $('.my-element').click(function() {
    var data = this.dataset;
    var message = {
        object: data.object,
      objectName: data.objectName,
    }
   
    window.parent.postMessage(message);
  });
});

In .lp document which includes the visualization via iframe use this code to get the message:
Code:
window.addEventListener('message', function(event) {
  console.log('event data', event.data)
}, false);

Hello, it works thanks for the help!