Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
JavaScript: Making a container closing X symbol output an action 'signal'

I have a container that is opened by a button (I have made it toggle so can close when re-clicking on the button using a bool variable (AreaContainerDialogOpen). The problem I have is the container has a window closing symbol: X top right which of course doesn't interact with the AreaContainerDialogOpen variable so clicking on the button doesn't always work as it has to turn off before it can turn back on so need to click twice if the X has been used to close. My question is: is there a way to get the X close action and set AreaContainerDialogOpen=false (preferred solution) ? Or can I remove the X closing symbol?

The container

   <div id="AreaContainer" class="container-fluid scrollBox fluidCentrePosition" style="display:none" title="Area">

The Button

 <button id="selectPRDAreas" class="btn btn-outline-dark" onclick="selectPRDAreas()">PRD Areas</button>


function selectPRDAreas()
{
            if (AreaContainerDialogOpen == false) {
                console.log("Opening AreaContainer");
                $("#AreaContainer").show(); 
                $("#AreaContainer").dialog();
                AreaContainerDialogOpen = true;
                //do stuff
    }
            else if (AreaContainerDialogOpen == true) {            
                $("#AreaContainer").dialog("close");
                AreaContainerDialogOpen = false;
            }
}

Thanks for your help, fairly new to javascript.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!