Results 1 to 4 of 4

Thread: To get the new value for global variable without callbacks, listeners in sencha touch

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default 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!!

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
      0  

    Default

    could you please post your code?

  3. #3
    Sencha User
    Join Date
    May 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    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

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
      0  

    Default

    Ok, so, in that case, all you have to do is declare a global.js in your html, something like this:

    HTML:
    Code:
    <!-- 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>
    Global.js
    Code:
    var actualValue = 'something';
    And now, you can use variable 'actualValue' in any *.js you want.
    Good luck man.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •