1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    235
    Vote Rating
    0
    chandan.behura is on a distinguished road

      0  

    Default syncronous calls

    syncronous calls


    Hi,
    How i will make a function syncronous.
    After calling a function i have some lines of code. But i want that after calling the function completely i should able to execute the bellow lines of code.
    Code:
     DGPPrefFilterStore.load({
                 params : {prefName : prefName},
                  scope : this,
                      callback: function(records, operation, success) {
    
                            var RegionPrefStr=DGPPrefFilterStore.last().data.region;
                            selectedRegion = RegionPrefStr.split(",");
                            controller.populateSubRegionAndCountry(selectedRegion);//function in another controller shown bellow
                            var regionDisplayField = Ext.getCmp('regionTip');
                            controller.setDisplayField(selectedRegion,regionDisplayField,maxRegion);
                            
                            var subRegionPrefStr=DGPPrefFilterStore.last().data.subRegion;
                            selectedSubRegion = subRegionPrefStr.split(",");
                            var subRegionDisplayField = Ext.getCmp('subRegionTip');
                             console.log("before pref dispaly gield"+selectedSubRegion);//should prin 2nd but printing first
           
                   
                              }
                            });
    
    
    populateSubRegionAndCountry : function(selectedRegion){
    
        var subRegionStore = Ext.data.StoreManager.lookup('deliveryGroupPerformances.SubRegionStore');
        var countryStore = Ext.data.StoreManager.lookup('deliveryGroupPerformances.CountryStore');
        selectedProcessingRegion = [];
        subRegionStore.removeAll();
         if(selectedRegion.length == 0 || selectedRegion.length == maxRegion){
                
                selectedProcessingRegion = "All";
            }
            else{
                selectedProcessingRegion.length = 0;
                for(var i = 0; i < selectedRegion.length; i++)
                selectedProcessingRegion.push("'"+selectedRegion[i]+"'");
                }
            alert(selectedProcessingRegion);
            subRegionStore.load({
                 params : {region : selectedProcessingRegion},
                 scope : this,
                 callback: function(records, operation, success) 
                 this.defaultSubRegion();  //calling to a defaultSubRegion function given bellow in same controller
               }
            });
        },
    
    
    defaultSubRegion : function(){
      
        var subRegionStore = Ext.data.StoreManager.lookup('deliveryGroupPerformances.SubRegionStore');
         maxSubRegion = subRegionStore.getCount();
         subRegionStore.queryBy(function(record) {
                    selectedSubRegion.push(record.get('subRegion'));
            });
         var subRegionDisplayField = Ext.getCmp('subRegionTip');
         console.log("before default dispaly field"+selectedSubRegion);//print satement should come firsr
      },
    Hierarchy is inside a callback() i have called populateSubRegionAndCountry() and have a print statement(say X). Inside the populateSubRegionAndCountry() there is another function which is calling defaultSubRegion() and inside defaultSubRegion() ihave another print statement(say Y).

    so i want to
    print X and then Y syncronously but getting the Y printed first then X

    How i make it syncronous call.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,790
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I would stay away from sync requests. The reason is the browser will not allow any interaction while a request is being made then.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi