0

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
 }

1 Answer 1

1

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
        }


    });

}
Sign up to request clarification or add additional context in comments.

5 Comments

I believe this worked, just having other issues at the moment, but wanted to say thanks. Will try to reply back to update.
You're welcome. If you have other issues, feel free to update the question.
UPDATE: It looks like in the updateLeftPanel, the second set of data is still not there. But in the firefox debugger, I can see the data returned and populated from the fetch process.
What happens if you console.log(record[0]) before updateLeftPanel?
My issue was compounded by my JSON building skills :) The answer is the correct one, thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.