Edit:
One thing that I've decided sort of works. Is passing a function as a parameter to getList
that you want it to go to when successful. That way you can call
getList("list1", functionForList1)
getList("list2", functionForList2)
function functionforList1(list){
// do stuff
}
function functionforList2(list){
// do *other* stuff
}
function getList(listName, goToFunction) {
var get = function (callback) {
// blahblahblah
currentcontext.executeQueryAsync(function () {
callback(null, listItemCollection);
}, function (a, b) {
callback(new Error(b.get_message()));
});
};
get(function (error, listItemCollection) {
if (error) {
alert(console.error(error));
return;
}
goToFunction(listItemCollection);
});
}