I have the following code, where i'm unable to get a reference to the parent object inside OnKeyUp function. I understand that in the OnKeyUp method, "this" refers to the textbox. But how do i access the parent object so that var textboxID gets me the correct value ?
function $MyObject() {
this.Control = {
inputBox: "#inputBox1",
name: "Control1",
BindEvent: function () {
$(this.inputBox).keyup(this.OnKeyUp);
},
OnKeyUp: function () {
var textBoxID = this.inputBox;
alert(textBoxID);
}
}
}
$(document).ready(function () {
var object1 = new $MyObject();
object1.Control.BindEvent();
});