Hybrid View

  1. #1
    Ext User
    Join Date
    Jul 2008
    Location
    Stuttgart, Germany
    Posts
    51
    Vote Rating
    0
    TomToms is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    You can't do it like that.

    You will have to process the next item in the list in a callback.

  3. #3
    Ext User
    Join Date
    Jul 2008
    Location
    Stuttgart, Germany
    Posts
    51
    Vote Rating
    0
    TomToms is on a distinguished road

      0  

    Default


    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?

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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.

  5. #5
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    You need to get a firm grip on asynchronous javascript.

  6. #6
    Ext User agodinhost's Avatar
    Join Date
    Aug 2008
    Location
    Rio de Janeiro.
    Posts
    25
    Vote Rating
    0
    agodinhost is on a distinguished road

      0  

    Default


    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!