1. #1
    Sencha Premium Member
    Join Date
    May 2013
    Location
    Stevenage, United Kingdom
    Posts
    44
    Vote Rating
    0
    uzair.sheikh is on a distinguished road

      0  

    Red face button tap resets to first index of array everytime tap

    button tap resets to first index of array everytime tap


    I am trying to build logic but can't really workout.

    - I have two button, forward and backward.
    - An array which contains Key values from the LocalStorage (e.g an array with 4 indexes contains keys from localstorage)
    - First time my form loads, I get first index of array and show the related data from localstorage into the form filelds (all fine here
    - When I click next button, I increase the array index by 1 to get next records from LocalStorage (all fine here
    - (This is where problem is ) But when I click next button again, ofcourse it calls the button tap again and runs my for loop (inside the button tap event function) from start and gets me the index at 1 again.

    Any suggestions please?
    Thanks in advance.

  2. #2
    Sencha Premium Member
    Join Date
    May 2013
    Location
    Stevenage, United Kingdom
    Posts
    44
    Vote Rating
    0
    uzair.sheikh is on a distinguished road

      0  

    Default Any Idea?

    Any Idea?


    Any idea guys?

    Is it possible to define a variable globally and so that it should be accessible in my button tap events and should not be reset every-time I tap button?

  3. #3
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,207
    Vote Rating
    120
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Someone would need some code to point you in the right direction.

    I suspect that you have formed a bad closure or you're holding onto a reference or you have a global variable... Hard to guess without seeing the code.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

Thread Participants: 1