-1

I have following code:

var bootboxresult;

bootbox.prompt('Please enter some data', function(result) {
if (result != null) {
bootboxresult = result;
}});

alert(bootboxresult);

if(bootboxresult === null)
{
return;
}

if(bootboxresult != null)
{
Some Code To Excecute
}

The code displays the prompt box, but always the content of the "bootboxresult" variable is null or undefined.

I need that the further code should wait for the bootbox.prompt() to store the value in the "bootboxresult" variable.

Please advise.

Karan Tongay
  • 197
  • 1
  • 17
  • Possible duplicate of [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – CBroe Sep 21 '16 at 16:09
  • Thanks @CBroe, it helped and cleared my Synchronous and Asynchronous call concepts. – Karan Tongay Sep 22 '16 at 07:02

1 Answers1

1

I think you can write all your code inside call back of bootbox. See example below.

        var popup_content = "<b>Are you sure?</b><br><br>Do you want to delete?";
        bootbox.confirm(popup_content, function(result) {
              if(result){
                  // Write all your code here.  

              }else{
                 // else part code goes here
              }

        });
Saji
  • 1,374
  • 1
  • 12
  • 19