J
Joel Whitehouse
The idea is to have a class wrapper for a single variable. Whenever the
variable is set with a new value through the function setValue(), I want
the event function "onchange" to be triggered.
Here's my code:
---------------------------------------
function Field()
{ var that = this;
var _data = null;
//Events
this.onchange = function(d){};
this.setData = function(d)
{
_data = d;
//I've tried calling onchange() so many ways. Documented here
//are the errors each attempt produces
//IE: "Object expected"
//FF: "that.onchange is not a function"
that.onchange(d);
//IE: "Object expected"
//FF: "this.onchange is not a function"
this.onchange(d);
//IE: "Object expected"
//FF: "onchange is not defined"
onchange(d);
};
this.getData = function()
{
return _data;
};
}//end of Field()
---------------------------------------
For some reason I can't access the onchange() function from setData().
How can I fix that? Thanks so much in advance!
-Joel
variable is set with a new value through the function setValue(), I want
the event function "onchange" to be triggered.
Here's my code:
---------------------------------------
function Field()
{ var that = this;
var _data = null;
//Events
this.onchange = function(d){};
this.setData = function(d)
{
_data = d;
//I've tried calling onchange() so many ways. Documented here
//are the errors each attempt produces
//IE: "Object expected"
//FF: "that.onchange is not a function"
that.onchange(d);
//IE: "Object expected"
//FF: "this.onchange is not a function"
this.onchange(d);
//IE: "Object expected"
//FF: "onchange is not defined"
onchange(d);
};
this.getData = function()
{
return _data;
};
}//end of Field()
---------------------------------------
For some reason I can't access the onchange() function from setData().
How can I fix that? Thanks so much in advance!
-Joel