I have an object like this:
objectx = {
1: {
name: "first",
loadFunction: function() {
$(target).load("http://stackoverflow.com #question", function() {
// do something else
});
}
},
2: {
name: "second",
loadFunction: function() {
$(target).load("http://stackoverflow.com #answer", function() {
// do something else
});
}
}
}
When I call the functions with objectx[1].loadFunction(), they don't have the local context, so I would have to pass everything as argument or make my variables global. For example:
function doSomething() {
var target; // this variable holds a reference to a DOM object
objectx[1].loadFunction()
}
target is not defined
How do I execute the functions so that they are aware of the context they are called from?