Logic Machine Forum
Change image from Url - 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: Change image from Url (/showthread.php?tid=2447)



Change image from Url - DGrandes - 01.02.2020

Hi,

Is there anyway to change an image in JS depending of an object?

I have an object that update url that give me an image and I want to show it in visualization.

Thanks


RE: Change image from Url - Erwin van der Zwart - 01.02.2020

Hi,

Yes you can do that (off course) (:

Add a image to your visu with a default remote URL and give it a additional class 'dynamic', add a 250 byte object that holds the dynamic URL, in this sample '1/1/1' and add this to your custom JS:
Code:
$(function(){
  if (typeof grp === 'object') {
    grp.listen('1/1/1', function(obj, state) {
      $('.dynamic').find('img').attr("src", obj.value)
    },true);
  }
});
BR,

Erwin