Logic Machine Forum
Add a listener when a widget closes - 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: Add a listener when a widget closes (/showthread.php?tid=579)



Add a listener when a widget closes - Mirco - 27.01.2017

Hi,
is there a way to detect, via javascript, when a widget closes?

Thanks!


RE: Add a listener when a widget closes - admin - 27.01.2017

Not directly, but as a work-around you can create a timer which checks widget state each second:
Code:
var widget = $('#widget-1'), visible = false;

setInterval(function() {
  var state = widget.is(':visible');
  if (state != visible) {
    visible = state;
    console.log('widget visibility state', visible);
  }
}, 1000);



RE: Add a listener when a widget closes - Mirco - 27.01.2017

Than you, it works! Smile