Hello all. I'm trying to work my way around creation of Objects and prototyping. First time I'm really trying to OOP route, and not resorting to simply using basic function.
Below is my class definition and prototype.
Next I create a user array populated by xml. For each user I'm looking to instantiate the object, then proceed by calling the 'setAlias' method.PHP Code:function user(){
//Declaring Variables
this.alias = "Sample Name";
}
user.prototype.getAlias = getAlias;
user.prototype.setAlias = setAlias;
function getAlias(){
return this.alias;
}
function setAlias = function(val){
this.alias = val;
}
When I make a call to the 'Test Object' function to see if the property is being correctly set. the function declartion is returned as a string. ie: the alert displays the following:PHP Code:UserList = new Array();
<xsl:for-each select="UserList/User">
UserList[<xsl:value-of select="position()-1"/>] = new user();
var tmpFc = FcList[<xsl:value-of select="position()-1"/>];
tmpFc.setAlias = "<xsl:value-of select="Alias"/>";
</xsl:for-each>
function TestObject(){
alert(UserList[0].getAlias);
}
I would expect to get the property returned not the function declaration. I'm pretty certain I'm making a simple error, but I'm lost. Any help is appreciated at this point.PHP Code:function(){
return this.alias;
}
Thank you.


Reply With Quote

Bookmarks