can't block execution of JavaScript code until some event (such as closing
your lightbox-style confirmation) occurs.
The best you can do is to call another function when the event happens. This
is why every asynchronous JavaScript API uses callback functions.
I haven't looked at any of the plugins you're talking about, but I'm sure
they all work that way. (Or perhaps they fire a custom event, but that's
really the same thing as calling a callback function.)
So instead of code like your example:
var value = prompt( 'enter value' );
alert( value );
You'd expect to use a pattern like this:
prompt( 'enter value', function( value ) {
alert( value );
});
-Mike
> From: pantagruel
>
> Hi,
>
> I've seen a number of jquery prompt replacements that allow
> you to have a customizable prompt of some sort but none that
> allow you to actually use it the way a prompt is normally
> used - that would say var x = prompt("please enter your
> value"); alert(x);
>
> Is there anything like that?
>
> If not - I have a situation like this where I have functions
> that take a function as a parameter - for example:
>
> newProc(Command('info'));
>
> Command returns a value based on, in some cases at least, the
> value a user inputs in response to a prompt.
>
> Does anyone have an example of how you would do that using
> any of the prompt replacing libraries?
>
No comments:
Post a Comment