user1700945
user1700945

Reputation: 125

Jquery CallBack Parameters

Not sure what I am doing wrong here, but let me setup the scenario.

In the beginning, a store(resultsStore) is being populated with data and being displayed via a function call.

Now, an intermediate step of obtaining more data by way of another store is needed and passing both sets to the original function.

I have tried many variations of the below, but the two datasets do not seem to be passed to the updateLeftPanel function, the first one is there fine, the second says "undefined". Anything obvious I am missing?

resultsStore.load({
    params: {
        'certid' : certId
    },
    callback: function(record,operation,success){
        updateRightPanel(record[0].data);  // code not shown,works fine
        //updateLeftPanel(record[0].data);   // original call

        loadCriteriaStore(record[0].data);  // new call


    }
});

function loadCriteriaStore(data)
{
    criteriaStore.load({
        params: {
            'edition' : data['Edition']
        },
        callback: function(record,operation,success,data){
            updateLeftPanel(data,record[0].data);  
            // orig data first, new dataset second
        }


    });

}

 function updateLeftPanel(data, dataa){ 
 // code here
          dataa object still unpopulated
 }

Upvotes: 0

Views: 76

Answers (1)

gen_Eric
gen_Eric

Reputation: 227240

In the callback in the loadCriteriaStore function, you are assigning 4 parameters. I'm assuming that it only passes 3.

So, in that callback, the data that contains your data is being overwritten by a new "local" data, that's undefined.

function loadCriteriaStore(data)
{
    criteriaStore.load({
        params: {
            'edition' : data['Edition']
        },
        // Get rid of the ",data" here
        callback: function(record,operation,success){
            // the `data` param will be the value passed to `loadCriteriaStore`
            updateLeftPanel(data,record[0].data);
            // orig data first, new dataset second
        }


    });

}

Upvotes: 1

Related Questions