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

135
Views
Wait For Response Before Continuing - Like Prompt()

I have a function that relies on a confirm.js prompt input. I want the function to wait for the input to be fulfilled prior to continuing anymore. In the same way prompt() waits for the ok button to be pressed, I want my function to wait for a button click event before it returns and proceeds.

Right now I attempted a Promise (not familiar at all):

function dostuff(){
    return new Promise(function(resolve, reject) {
        $.confirm({
            content: '<input id="input">',
            buttons: {
                done: {
                    text: 'Done',
                    action: () => {
                        resolve(); // resolve promise when button is pressed
                    }
                }
            }
        });
    }).then(function(){
      return input.val();
    });
  }
}

But using the function doesn't pause the execution of the remaining script. For example:

console.log("start")
dostuff().then(function(result) {
    console.log(result);
});
console.log("end")

Will print:

start
end
undefined

Then finally the input value once I've pressed enter.

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!