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.

Open/Close Widget
#1
Good afternoon,

I wanted to ask if it is possible to change the image of an object depending on whether the associated Widget is open or closed, without having to use Javascript.

Cheers
Reply
#2
This can't be done without Custom JS. Do you want to change the icon of the element that opens the widget or something else?
Reply
#3
(01.02.2021, 07:49)admin Wrote: This can't be done without Custom JS. Do you want to change the icon of the element that opens the widget or something else?

I just want to change the icon of the element
Reply
#4
Use an object that is not connected to any control so the its value is always 0. Change widget-5 to your widget element ID, additional class for the opening element is widget-opener, change icon paths as needed.
Code:
$(function(){
  var widget = $('#widget-5');
  var img = $('.widget-opener').find('img');
  var icon_on = '/scada/resources/icons/ok-active.svg';
  var icon_off = '/scada/resources/icons/ok.svg';
  
  widget
    .on('widget-show', function() { img.attr('src', icon_on); })
    .on('widget-hide', function() { img.attr('src', icon_off); });
});
Reply


Forum Jump: