1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    22
    Vote Rating
    0
    soniamru is on a distinguished road

      0  

    Exclamation Unanswered: strange behavior of ajax call or store load

    Unanswered: 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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,047
    Answers
    3493
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread