The fastest easiest way to get it right.

confirm

NAME

x6dialogs.confirm

FUNCTION

The Javascript method x6dialogs.confirm replaces the native Javascript confirm() function with one that is stylistically consistent with the rest of the application.

Like Javascript's native confirm() function, execution


  • stops* until the user answers the question. This makes coding far easier because you do not have to code anonymous callback functions.

When this alert is active, all keyboard events are suppressed except 'Y' and 'N'.

EXAMPLE

Here is a usage example:

       if(x6dialogs.confirm("Do you really want to delete?")) {
           // code to delete
       }
       else {
           u.events.debug("user chose not to delete");
       }

PORTABILITY

Javascript does not natively support an elegant way to pause execution. For instance, it does not have a "sleep" function that would allow a low-CPU idefinite loop to be executing while waiting for user input.

We could solve this by throwing caution to the wind and doing an indefinite loop anyway, which checks over and over to see if the user has responded, but this spikes CPU usage and is very bad form.

The technique used by x6dialogs.confirm is unusual, but it has the benefit of being extremely low on CPU power and extremely low on network bandwidth. The approach contains an indefinite loop that makes a call to the program phpWait.php, which does a sleep for 1/4 second and returns. Even at four calls per second, the overall CPU and network bandwidth is practically zero.

Therefore, x6dialogs.confirm has a dependency that the php file phpWait.php be present in the web server's public root. This is handled automatically by Andromeda, but you must provide such a file if you use this object in a non-Andromeda application.

User Comments

There are no user comments yet on this page.


Add A Comment

Comments will not appear until after they are moderated. Comments are usually moderated within a few hours on weekdays, but may take longer on weekends and holidays.

Name or nickname: (This will appear with your comment)


Email (this will never be displayed)


Enter your comment here. Use [b] and [/b] for bold, [i] and [/i] for italic, and [pre] and [/pre] for code samples. All literal HTML and PHP that you enter will be escaped out and displayed as you enter it.


Home |  Documentation |  Download |  Credits |  Contact |  Login
Andromeda © Copyright 2004-2010, Licensed under the GPL Version 2