Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since the callback is asynchronous (at least, in the sense that it's waiting on the user to do something), it might be easier to handle what you need to inside the callback:</p> <pre><code>function confirm() { jConfirm('are you sure?', 'Confirmation Dialog', function(r) { if (r) doSomething(); }); } </code></pre> <hr> <p>@klogan [comments]</p> <p>I assume you got these from <a href="http://abeautifulsite.net/notebook/87" rel="nofollow noreferrer">here</a>?</p> <p>The page gives you your answer: (look under <strong>Usage</strong>)</p> <blockquote> <p><em>These methods do not return the same values as confirm() and prompt(). You must access the resulting values using a callback function. (See the demo for more details.)</em></p> </blockquote> <hr> <p>@klogan</p> <p>The point I'm trying to make is that there isn't really an easy way to accomplish what you want. You're trying to correlate <strong>procedural</strong> and <strong>event-driven</strong> programming -- something JavaScript doesn't help you do.</p> <p><strike><i> The simplest (though, <strong><em>risky</em></strong>) solution is to use a pseudo-infinite-loop. But, if <code>callback</code> never gets called, you now have an actual infinite loop. And, depending on the JavaScript engine, you might kill the browser waiting.</p> <p>Point: <strong><em>Your best bet is to avoid</em></strong> <strike>this</strike> <strong><em>trying to force event-driven into procedural.</em></strong></p> <pre><code>function confirm() { var result = false; var response = false; jConfirm('are you sure?', 'Confirmation Dialog', function(r) { result = r; response = true; }); while(!response) continue; // wait return result; } </code></pre> <p></i></strike></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload