Click to See Complete Forum and Search --> : Calling this.method();


OhLordy
12-24-2003, 04:23 AM
How can I call a method from withinf the class?
This is the sort of thing I mean


function TheClass()
{
var aVariable;
}

TheClass.prototype.methodOne = function()
{
this.methodTwo();
}

TheClass.prototype.methodTwo = function()
{
//here is some other stuff
}

Thanks
Rob

fredmv
12-24-2003, 04:38 AM
<script type="text/javascript">
//<![CDATA[
function TheClass()
{

}

TheClass.prototype.foo = function()
{
alert('Hello!');
}

TheClass.prototype.bar = function()
{
this.foo();
}

var foo = new TheClass();
foo.bar();
//]]>
</script>