Logic Machine Forum
Button of widget doesn't change immage - 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: Button of widget doesn't change immage (/showthread.php?tid=441)



Button of widget doesn't change immage - Mirco - 27.10.2016

Hi,
How can I change the immage of the button when a widget is open, and rechange it to the original, when the widget is close?
Because I put an immage in the "Icon ON" and another one in the "Icon OFF" properties of the button that open the widget, but it doesn't change..  What does these properties for?

Thanks


RE: Button of widget doesn't change immage - admin - 27.10.2016

On/Off image is linked to object or status object value. For now it's not possible to change the icon depending on widget state unless you write some custom JavaScript.


RE: Button of widget doesn't change immage - Mirco - 27.10.2016

Ok, thanks!
How can I see if a widget is open/close in JavaScript?

I have resolve my previous question, but now I am not able to change the image of an object with JavaScript, do you know how to do it?
I tryed some istructions but no one worked..

This is my code:
Code:
$(function()
{
 var widgetS = false, widgetF = false;
 
 function openWidget(id_icon)
 {
   $(id_icon).css("background-image", "/scada/resources/icons/Button_Preessed.svg");  //This doesn't work
 }
 
 function closeWidget(id_icon)
 {
   $(id_icon).css("background-image", "/scada/resources/icons/empty.svg");  //This doesn't work
 }
 
 
 $(".widgetS").on("click", function()
 {
     if (widgetS == false)
   {
     openWidget(".widgetS");
     widgetS = true;
   }
   else
   {
     closeWidget(".widgetS");
     widgetS = false;
   }
   
   if (widgetF == true)
   {
     closeWidget(".widgetF");
     widgetF = false;
   }
 });
 
 $(".widgetF").on("click", function()
 {
     if (widgetF == false)
   {
     openWidget(".widgetF");
     widgetF = true;
   }
   else
   {
     closeWidget(".widgetF");
     widgetF = false;
   }
   
   if (widgetS == true)
   {
     closeWidget(".widgetS");
     widgetS = false;
   }
 });
 
 $(".pageS").on("click", function()
 {
     if (widgetS == true)
   {
     closeWidget(".widgetS");
     widgetS = false;
   }
   
   if (widgetF == true)
   {
     closeWidget(".widgetF");
     widgetF = false;
   }
 });
 
 $(".pageF").on("click", function()
 {
     if (widgetS == true)
   {
     closeWidget(".widgetS");
     widgetS = false;
   }
   
   if (widgetF == true)
   {
     closeWidget(".widgetF");
     widgetF = false;
   }
 });
});



RE: Button of widget doesn't change immage - admin - 27.10.2016

Try this instead:
Code:
$(id_icon).find("img").attr("src", "/scada/resources/icons/Button_Preessed.svg");



RE: Button of widget doesn't change immage - Mirco - 27.10.2016

Thank you very much, it works now!