Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default Unanswered: Global variable in sencha touch

    Unanswered: Global variable in sencha touch


    SALAM
    I want to save a value from a web service response to use it in another view of my app.
    i did this:

    Code:
    Ext.Ajax.request({
      url: 'http://localhost:10000/Service/test/'+urtemp,
      success : function(response) {
      console.log(response);
      var user = eval('('+ response.responseText+ ')'); 
      console.log(user);
       App.variable = user.clientID;  
       var nv = user.clientNOM;
       var pr = user.clientPRENOM;
     if(nv !== "null") {
            console.log("client ID "+App.variable);
      		Ext.Msg.alert("Bienvenue Monsieur",pr+" "+nv);
                    Ext.getCmp('status').setTitle('Gerer votre compte');
                    Ext.redirect('Banking/compte');
                    window.location = redirect; 
          } 
    else {Ext.Msg.alert("Mot de passe ou login incorrecte","veuillez reeseyer");} 
      },
      
      failure: function(response) {
    	  Ext.getCmp('res').setValue(response.status);
     }
     });
    and when i want to use it in a store like this :
    Code:
    
    Ext.regStore('storeCPT', {
     model: 'compte',
     autoLoad: true,
     proxy: 
     {
     type: 'ajax',
    url: 'http://localhost:10000/Service/compteID/'+App.variable,
     reader: 
      {
       type: 'json',
      }
     }
    });
    it doesn't work.
    how can i declare and call a global variable in sencha touch.
    thank you

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default


    SALAM all.
    i found a loution by adding a variable in app.js file like this
    Code:
    Ext.regApplication({
        name: 'App',
        defaultUrl: 'Home/index',
    launch: function() {
       this.viewport = new App.views.Viewport();
        },
    variable: ''
    });
    and i during the execution of the app, i add a value to this vairable like this

    App.variable = user.clientID;

    but when i want to work with this variable, it's failed. here is what i did:

    Code:
    
    
    
    Ext.regStore('storeCPT', {
     model: 'compte',
     autoLoad: true,
     proxy: 
     {
     type: 'ajax',
    url: 'http://localhost:10000/Service/compteID/'+App.variable,
     reader: 
      {
       type: 'json',
      }
     }
    });
    what can i do to fix that.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    Try just something like this:

    Code:
    url: 'http://localhost:10000/Service/compteID/'+variable,
    Without the "App."

    Also, you can use a listener in your store and write console.log(App) to see what it got.
    Good luck.

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default


    SALAM
    thank you izak for youre response but when i removed the App, my view failed to start. and about the listener, how can i implement it ?

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    Hi, in your store, add this:

    Code:
    Ext.regStore('storeCPT', {
    model: 'compte',
    autoLoad: true,
    proxy: 
    {
    	type: 'ajax',
    	url: 'http://localhost:10000/Service/compteID/'+App.variable,
    	reader: 
    	{
    		type: 'json',
      	}
    },
    listeners: {
        'load': function(store) {
            console.log(store);
        }
    }
    });
    Good luck!

  6. #6
    Sencha User
    Join Date
    Mar 2012
    Location
    Tunisia
    Posts
    74
    Vote Rating
    1
    zied jouini is on a distinguished road

      0  

    Default


    SALAM izak
    sorry but it do the same thing

  7. #7
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    Look at the console to see if your store has data and see the url too .... and rule out that possibility.

Thread Participants: 1

Tags for this Thread