This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Button of widget doesn't change immage
#1
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
Reply
#2
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.
Reply
#3
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;
   }
 });
});
Reply
#4
Try this instead:
Code:
$(id_icon).find("img").attr("src", "/scada/resources/icons/Button_Preessed.svg");
Reply
#5
Thank you very much, it works now!
Reply


Forum Jump: