1

I am try to global variable in one entire view, could not done it.

initialize : function(){
    this.callParent();

    this.nameValue=0;
if(name="ram")
    this.nameValue=1;
     console.log("Test 1 -"+this.nameValue);
}else {
 this.nameValue=0;
     console.log("Test 2 -"+this.nameValue);
}

}

it would be access value form button tap like this:

onSubmitButtonTap: function () {
 console.log("Button Tap Here");
 console.log("Test Def-6-"+this.nameValue);
}

But i could not access it, it display always 0. I have gave input ram, then it also give me 0.why this. global variable could not works fine.

1 Answers1

2

You can use the auto setters/getters like this:

config: {
    nameValue: 0,

    listeners: {
        initialize : function() {
            if (name="ram") {
                this.setNameValue(1);
                console.log("Test 1 -" + this.getNameValue() );
            } else {
                this.setNameValue(0);
                console.log("Test 2 -" + this.getNameValue() );
            }
        }
    }
},

onSubmitButtonTap: function () {
    console.log("Button Tap Here");
    console.log("Test Def-6-" + this.getNameValue() );
}
Nico Grunfeld
  • 1,133
  • 1
  • 8
  • 19
  • Would you please give me some idea of this problem: http://stackoverflow.com/questions/18075538/how-to-make-carousel-infinite-in-sencha –  Aug 07 '13 at 07:55
  • @Nico Grunfeld can you please look onto this http://stackoverflow.com/questions/18397623/how-to-get-value-form-record-in-sencha-touch – surhidamatya Aug 23 '13 at 09:40