-
12 Aug 2008 6:58 AM #1
How getting an asynchronous MsgBox synchronous?
How getting an asynchronous MsgBox synchronous?
Hi everybody

my problem is the following:
I have a popup with a grid, a textfield and some buttons (save, load, delete,...) on it. If the user clicks on the save-button and the value of the textfield is the same like a value of the grid, he gets a confirm-msgBox, if he really wants to save the value.
Because msgBox is asynchronous, the script runs through, without waiting for user interaction (choosing yes or no at the confirm-msgBox). How can I prevent this?
My code looks like the following:
[code]
// Many many code after the save-button is pressed..
var lenge = querystore.data.length; // the length of my store
for (var z = 0; z < lenge; z++) {
if (queryname == querystore.data.items[z].data.query) { // queryname is the value of the textfield // if the value of the textfield == one of the items of the store...
Ext.Msg.show({
title: 'Abfrage vorhanden',
msg: 'Die Abfrage ist bereits vorhaden, soll diese
-
12 Aug 2008 7:03 AM #2
You can't do it like that.
You will have to process the next item in the list in a callback.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
12 Aug 2008 7:54 AM #3
Hi Animal,
thanks for your help, but could you please post me an example, because I'm not sure, if I got you right...
But I think, I have a workaround for the problem:
I create a boolean before the for-loop and set it to true. If the textfield == a value of the store, I set it to false. After the for-loop, I check the boolean, if it is false or true and run (if it is true) the run_the_request()-function.
To handle the user input with the yes and no-button, I create an on.click() with window.getElementById() and check what button was pressed.
Do you think, this might work?
-
12 Aug 2008 7:57 AM #4
You can't use a for loop. You must process the next item in a callback. By "example" you mean do the work. You do it.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
12 Aug 2008 10:01 AM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
You need to get a firm grip on asynchronous javascript.

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
5 Sep 2008 9:03 AM #6
Hi, I have the same requirements here.
I agree that a loop waiting for the popup to be closed would be a really bad idea but I can't see any other way to do that ...
Requirements, omg!
-
5 Sep 2008 9:20 AM #7
As mentioned, you just really need to learn a different way of thinking about the problems when it comes to event based programming. There are always ways of chaining events if you think about it the right way.
-
9 Sep 2008 7:33 PM #8
devnull, I do not disagree with you about the event based programming - I'm just saying that would be really nice one function/method/class to da that. I resolved my problem just using the jscript function 'confirm' but you already know that this function does not have the Ext look and feel.
IMHO: the requirements are more important than ANY techie talk.
-
9 Sep 2008 10:38 PM #9
Pass a callback function!
How difficult is that?Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
12 Sep 2008 5:41 AM #10
same requirement for me.
a callback doesn't help. i need a confirm message on a beforeSelect of a combobox, which stops the selection if not confirmed. but with a callback, the selecting will take place, as soon as the callback is called.
i use a normal js comfirm as well (which realy hurts me), cause it actually lets me return a false for the beforeSelectin general things are, what they look like


Reply With Quote