I have one backbone.js file (controller) and from there calling one function for five times to get the cached data for different roles. Function is being called for one of the role and pulled the correct data but does not execute for rest of the roles.
In short, it execute just for the first one not for all. But if I commented out first function call then it exeucte the 2nd one successfully. Really confuse why it runs only for the first one not for rest. Can any one please help me?
define(
'staffController',['jquery', 'underscore', 'backbone','staffModel'],
function ($, _, backbone, staffModel)
{
var self = this;
var innerStaff =1;
var security=2;
var outerStaff=3;
var cleanerStaff=4;
var deliveryStaff=5;
function load() {
/// rest staff model code is here
ReadData(self, 1); // Executed
ReadData(self, 2); // not executed
ReadData(self, 3); // not executed
ReadData(self, 4); // not executed
ReadData(self, 5); // not executed
}
function ReadData(self, staffType)
{
if(staffType == 1)
{
// load inner staff data
}
else if(stafeType == 2)
{
// load security data
}
else if(stafeType == 3)
{
// load outer staff data
}
else if(stafeType == 4)
{
// load data
}
else if(stafeType == 5)
{
// load data
}
}
}
);