The code below generates click functions for each given ID in the single-line array, using the uncommented code, I get the error "string is not a function". If I uncomment the commented code, and comment the single-line array, it does work well. However I prefer the approach with the singe-line array, to me, for obvious reasons.
Can anyone give me some good advice? Am I on the right path?
Thanks in advance.
// callme
function callme() {
alert("call me");
return true;
}
// create javascript object
//var adapter = {};
// set values - key contains: ID associated with link, button or tab - value contains: the function to call
//adapter['callme'] = callme;
//adapter['callme1'] = callme1;
//adapter['callme2'] = callme2;
//adapter['callme3'] = callme3;
var adapter = ["callme", "callme1", "callme2", "callme3"];
// foreach the object - key as ID - value as associated function
$.each(adapter, function(index, value) {
// click on listed ID
$("#"+ value).click(function() {
// call associated function
value();
});
// end foreach
});