I
ivanhoe
I've got constructor like this(just short example):
function Item() {
this.elem = document.body.appendChild(document.createElement('div'));
this.elem.onmouseover = this.mOver;
...
return this;
}
and mouse over method is something like:
Item.prototype.mOver = function() {
this.className='something';
}
now my question is about using 'this' inside function above...Am I
right that it is acctually 'this' reference from onmouseover, thus
referencing div element, not instance of Item class? How could I then
access the instance of Item class , from within mOver method?
It would be perfect if I could have only one object, the div element,
and then I could easily add methods and properties, and there would be
only one 'this' to work with....I know how to do it with 'regular' js,
but how to put that in OO form, so that I can create a new instance
with: new Item() ??
thanx,
ivan
function Item() {
this.elem = document.body.appendChild(document.createElement('div'));
this.elem.onmouseover = this.mOver;
...
return this;
}
and mouse over method is something like:
Item.prototype.mOver = function() {
this.className='something';
}
now my question is about using 'this' inside function above...Am I
right that it is acctually 'this' reference from onmouseover, thus
referencing div element, not instance of Item class? How could I then
access the instance of Item class , from within mOver method?
It would be perfect if I could have only one object, the div element,
and then I could easily add methods and properties, and there would be
only one 'this' to work with....I know how to do it with 'regular' js,
but how to put that in OO form, so that I can create a new instance
with: new Item() ??
thanx,
ivan