As someone who is attempting to take a more object oriented approach to my javascript programming I've hit a stumbling block which I'm sure is probably something very basic, but, take the following object implementation (assume that the jQuery object is available to this code):
function Foo()
{
this.someProperty = 5;
}
Foo.prototype.myFunc = function()
{
//do stuff...
};
Foo.prototype.bar = function()
{
//here 'this' refers to the object Foo
console.log(this.someProperty);
$('.some_elements').each(function()
{
//but here, 'this' refers to the current DOM element of the list of elements
//selected by the jQuery selector that jquery's each() function is iterating through
console.log(this);
//so, how can i access the Foo object's properties from here so i can do
//something like this?
this.myFunc();
});
};