Note: This question uses jQuery but the question has nothing to do with jQuery!
Okay so I have this object:
var box = new BigBox();
This object has a method named Serialize()
:
box.AddToPage();
Here is the method AddToPage()
:
function AddToPage()
{
$('#some_item').html("<div id='box' onclick='this.OnClick()'></div>");
}
The problem above is the this.OnClick()
(which obviously does not work). I need the onclick
handler to invoke a member of the BigBox
class. How can I do this?
How can an object refer to itself in an event handler?