I have some JavaScript functions in each page that I call them after jQuery is loaded.
The function in Questions.aspx
page is afterQuestions()
, the function in Default.aspx is afterDefault()
and so on ....
In my master page I am calling them like:
if(typeof(afterQuestion) == 'function') afterQuestions();
if(typeof(afterDefault) == 'function') afterDefault();
As the number of functions grew, I tried something like:
var _fs = [After, AfterDefault, afterSettings, afterQuestions];
for (var i = 0; i < _fs.length; i++) if (typeof (_fs[i]) == "function") _fs[i]();
But it doesn't work this way. Can you please help me how can I create an Array of functions and call them?
Edit: I think nobody had read the question well to see that the all functions won't exist at the same time and that was the problem creating the array. I solved it by adding created functions to a global array and the looping and excuting functions in that array