Results 1 to 2 of 2

Thread: strange behavior of ajax call or store load

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    22
    Vote Rating
    0
      0  

    Exclamation strange behavior of ajax call or store load

    hi everyone,
    I am implementing one page contain 3 tabs.on each tab i am calling different views (on click of each tab by dispatch) via controller's method . here i am creating different store in each view but model and JSON is same.
    if i switch between 3 tabs then on 3rd or 4th click AJAX call to json are getting doubled. like instead of making one JSON request it is making more than one request automatically increases that count if i go for next tab click. but i am getting data correct. Why it is making 3-4 ajax calls extra . as i'm calling three views and creating store new.
    following is rough structure of my code
    controller
    myController = new Ext.Controller({
    method1:function(){
    //call view
    },
    method2:function(){
    //call view
    },
    method3:function(){
    //call view
    },

    })

    view file

    myview=Ext.extend(Ext.Panel, {

    // docked items
    // three tabs or items of segmented button toolbar
    items: [{ text: 'tab1',
    id:'t1',
    pressed:true
    }, {
    text: 'tab2',
    id:'t2'
    },
    {
    text: 'tab3',
    id:'t3'

    }],
    listeners: {
    toggle: this.onSwitch
    scope: this
    }

    //some build items method that will create store and load data from json



    onSwitch:function(segButton, button, pressed){

    if(t1)
    {
    Ext.dispatch({ controller: myController,
    action: 'method1'
    });
    }
    /*similarly for other 2 tabs*/

    }
    })

    now first user will come at t1 tab when we try to switch from t1->t2 ,t2->t3 and t3->t1 now on last click it is making request twice to same json. again if user switch to other tab it doubles (count is not finite) request to json.
    don't know what is happening?where i am doing wrong?
    please help me......!!!!!!!!!!!!!!!!!!!
    Thanks in advance

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    You should not have arrays and objects as a property or else they are in danger of being shared among all instances of that class. Instead, you need to build a new array and object within a method that is fired when a new instance is created like the initComponent method.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •