-
7 Jun 2012 4:30 AM #1
Unanswered: To get the new value for global variable without callbacks, listeners in sencha touch
Unanswered: To get the new value for global variable without callbacks, listeners in sencha touch
Hi,
I want to access the value of the global variable. When i am accessing the value of this global variable inside any listener it is giving me updated value but when i am trying to use this value for config of any component it is not taking updated value. Rather it is taking the initial value only. Please suggest some way to access the updated value in config of any component.
Thanks!!
-
7 Jun 2012 7:18 AM #2
-
7 Jun 2012 7:29 PM #3
Hi,
Suppose I have a value in first js. For an example:
I have a value actualValue in firstFile.js file.
Now i want to use this actualValue in nextFile.js as a config of slider field:
upSlider = new Ext.form.FormPanel({
id:'sliderUp',
layout:'vbox',
items:[{
xtype : 'sliderfield',
value : actualValue,//I want to use it here.
minValue : -100,
maxValue: 100,
disabled:true,
listeners: {
change:{
fn :function(upSlider,thumb,new_val,old_val){
if(new_val>100||new_val<-100){
upSlider.thumbs[0].removeCls('x-thumb::before').addCls('slider');
}
}
}
}
},
{
layout:'hbox',
items:[
{
width:120,
height:8,
html: ['Max Value '+100],
},
{
width:140,
height:8,
html: ['Actual '+actualValue] // How do I get the value here also??
},
{
width:120,
height:8,
html: ['Min Value '+cgMin]
}]
}
]
});
How can i get the updated value of actualValue without any listener?
Thanks
-
8 Jun 2012 5:13 AM #4
Ok, so, in that case, all you have to do is declare a global.js in your html, something like this:
HTML:
Global.jsCode:<!-- CSS --> <link rel="stylesheet" href="resources/css/sencha-touch.css" type="text/css"> <!-- LIB --> <script type="text/javascript" src="resources/lib/sencha-touch.js"></script> <script type="text/javascript" src="resources/lib/global.js"></script> <!-- APP --> <script type="text/javascript" src="src/firstFile.js"></script> <script type="text/javascript" src="src/nextFile.js"></script>
And now, you can use variable 'actualValue' in any *.js you want.Code:var actualValue = 'something';
Good luck man.


Reply With Quote