Im creating a class to carry out certain functionalities.
Here is a snipet of the code where I am having the problem.
the "this.doThis()" needs to call the class function 'doThis' but at the moment it is thinking the 'doThis' method exists in the object 'theItem', but I dont know how to call the function 'doThis' properly.
Can anyone give me a hand?
Thanks a lot.
Here is a snipet of the code where I am having the problem.
Code:
function MyClass()
{
this.AddItem = function(id)
{
var theItem = document.getElementById(id);
theItem.onmouseclick = function()
{
this.doThis(); // <------ PROBLEM
}
};
this.doThis = function()
{
alert("Done it");
};
}
the "this.doThis()" needs to call the class function 'doThis' but at the moment it is thinking the 'doThis' method exists in the object 'theItem', but I dont know how to call the function 'doThis' properly.
Can anyone give me a hand?
Thanks a lot.