L
lister
Hi folks, newbie(ish) here.
I want to attach an event handler to a google map marker. I want the
event handler to call into a member function of the object that
created it.
eg.
MyMarkerClass.prototype.registerEventHandler()
{
GEvent.addListener(this.GoogleMarker, "click", function()
{
this.onClick();
});
}
MyMarkerClass.prototype.onClick()
{
alert("Clicked!");
}
Unfortunately at the time my inner function is called, "this" refers
to the google marker that generated the event, and not the
"MyMarkerClass" object that created the function.
How can I reference the "this" of MyMarkerClass, so that it calls into
the proper object?
Many thanks,
Lister
I want to attach an event handler to a google map marker. I want the
event handler to call into a member function of the object that
created it.
eg.
MyMarkerClass.prototype.registerEventHandler()
{
GEvent.addListener(this.GoogleMarker, "click", function()
{
this.onClick();
});
}
MyMarkerClass.prototype.onClick()
{
alert("Clicked!");
}
Unfortunately at the time my inner function is called, "this" refers
to the google marker that generated the event, and not the
"MyMarkerClass" object that created the function.
How can I reference the "this" of MyMarkerClass, so that it calls into
the proper object?
Many thanks,
Lister