Logic Machine Forum
Open Widget by Script - 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: Open Widget by Script (/showthread.php?tid=4155)



Open Widget by Script - sjfp - 22.07.2022

Hi looking for a method of opening a widget (377) via script when an object 0/2/22 is between 1 and 20 and closing it when 0/2/22 is 0
But only to open widget when parent page (vis page 358) is open. Don't want the widget to open on other screens around the home.

Think I saw something in the forum before, similar to this but cant find the post again.

Any help would be grateful.


RE: Open Widget by Script - Daniel - 22.07.2022

You probably refer to this
https://forum.logicmachine.net/showthread.php?tid=2532&pid=16206#pid16206


RE: Open Widget by Script - sjfp - 22.07.2022

(22.07.2022, 13:42)Daniel Wrote: You probably refer to this
https://forum.logicmachine.net/showthread.php?tid=2532&pid=16206#pid16206

No but it did take me towards , which is what i was looking at for inspiration 
$(function(){
 
  var openwidget = false;
 
  function openWidget(){ 
  if (currentPlanId == 353){
      if (openwidget == false){
          openwidget = true; 
        // Open widget
      $("#widget-377").removeClass("hide");
          // Position widget (absolute positioned)
      //document.getElementById("widget-5").style.top = "150px";
      //document.getElementById("widget-5").style.left = "150px";
      //document.getElementById("widget-5").style.width = "1024px";
    //document.getElementById("widget-5").style.height = "600px";
      }
  } else {
      // Condition to hide widget
      $("#widget-377").addClass("hide");
      openwidget = false;
    }
  }

  // Initial execution if needed
  openWidget();

  // Add event listener to control elements only for checking on each user input
  $('.item-control').on( "click", function() {
      openWidget();
  });
 
});