D
danny.dion
Hi ! I have a question about JScript :
I have an object class wich dynamically creates a control in the page.
Then it binds an event to that control, pointing on one of its methods
(the object's). This method, in turn, calls other of its own
methods...
The binding seems ok and the change() method does get called. But I
get an error message (This object does not support this property or
method) when I call other methods on the object.
I think that the implicit "this" object sent to the method does not
point to the right object instance...
Does anyone have a clue on how I might solve this ?
TextField.prototype.generateField = function() {
this.fieldReference = window.document.createElement("input");
this.fieldReference.type = "text";
this.fieldReference.name = this.fieldId;
this.fieldReference.id = this.fieldId;
this.fieldReference.value = this.value;
this.fieldReference.attachEvent("onchange", this.change);
this.fieldWrapperReference.innerHTML = "";
this.fieldWrapperReference.appendChild(this.fieldReference);
}
TextField.prototype.change = function() {
// Fired by the onchange event
this._setStyles();
this._updateChilds();
if (this.onChangeFunction != null) {
this.onChangeFunction();
}
}
I have an object class wich dynamically creates a control in the page.
Then it binds an event to that control, pointing on one of its methods
(the object's). This method, in turn, calls other of its own
methods...
The binding seems ok and the change() method does get called. But I
get an error message (This object does not support this property or
method) when I call other methods on the object.
I think that the implicit "this" object sent to the method does not
point to the right object instance...
Does anyone have a clue on how I might solve this ?
TextField.prototype.generateField = function() {
this.fieldReference = window.document.createElement("input");
this.fieldReference.type = "text";
this.fieldReference.name = this.fieldId;
this.fieldReference.id = this.fieldId;
this.fieldReference.value = this.value;
this.fieldReference.attachEvent("onchange", this.change);
this.fieldWrapperReference.innerHTML = "";
this.fieldWrapperReference.appendChild(this.fieldReference);
}
TextField.prototype.change = function() {
// Fired by the onchange event
this._setStyles();
this._updateChilds();
if (this.onChangeFunction != null) {
this.onChangeFunction();
}
}