I'm using the following now, which I'm sure has it's pro's and cons, but it seems to work for now.
function BaseClass( name ){
this.name = name;
}
BaseClass.prototype.getName = function() {
return this.name;
}
function SubClass( name ) {
var base = new BaseClass( name );
for ( func in base ) {
this[ func ] = base[ func ];
}
}
test = new SubClass( "test" );
alert( test.getName() );
On 11/10/06, Andrew Scott <[EMAIL PROTECTED]> wrote:
I am not a guru at this, but the 2 functions are running there own space, so FormProperty has no property named name which is what I belieb you are trying to set.
On 11/10/06, Pacific Fox <[EMAIL PROTECTED] > wrote:
Hi all,
I know it's JS, but I'm sure there are some JS gurus on here...
I've got a base object that works fine with named arguments when called
on it's own. However when I call the child object I get an error "arg
has no properties" (in firefox).
A simple test:
Property = function( arg ) {
/**
* Private properties
*/
var name = arg.name; // required, the name of the field
/**
* Priviliged methods, may be invoked publicly and may access private
variables
*/
this.getName = function() {
return name;
}
};
/**
* Class for form field properties, extends property
*/
FormProperty = function( arg ) {
/**
* Inheritance
*/
this.super = Property;
this.super( { name:arg.name } );
this.prototype = new Property;
}
//property = new FormProperty( { name:"myVar" } )
property = new Property( { name:"test" } )
alert( property.getName() );
Uncomment //property = new FormProperty( { name:"myVar" } )
to get the error.
Thanks in advance for any help.
http://www.pacificfox.com.au
Web Design, Web development, Graphic Design and Complete Internet Solutions
an industry leader with commercial IT experience since 1994 …
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---
Reply via email to
