> That may be because you're using prototype 1.4.
> You may consider upgrading to 1.7.

Indeed. 1.4 has been out of date for nearly 4.5 years, when 1.5 was
first released. At least as of 1.6 (released ~3.75 years ago, and now
superceded by 1.7), the correct syntax for using `Class.create` would
be:

var Person = Class.create({
    printName: function() {
        alert(this.name);
    }
});

You never have to do anything to `Person.prototype` directly (and in
fact, *replacing* it as shown in the OP's question would mess up the
inheritance and other features provided by `Class.create`).
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Jun 1, 3:23 pm, Eric <lefauv...@gmail.com> wrote:
> On May 31, 4:35 pm, maven apache <apachemav...@gmail.com> wrote:
>
> > 2011/5/31 Johan Arensman <johanm...@gmail.com>
>
> > > Hi,
>
> > > Mostly because with Class.create() you can make use of the various
> > > inheritance functionality in the Prototype framework.
>
> > But I see the prototype source code,the Class.create() just return a
> > function,can not find any inheritance functionality
>
> That may be because you're using prototype 1.4.
> You may consider upgrading to 1.7.
>
> Eric
>
>
>
>
>
>
>
>
>
> > > Seehttp://api.prototypejs.org/language/Class/create/formore
> > > information.
>
> > > Greetings,
> > >  Johan
>
> > > On Tue, May 31, 2011 at 3:26 PM, maven apache 
> > > <apachemav...@gmail.com>wrote:
>
> > >> Hi:
>
> > >> I am using prototype1.4 now.
>
> > >> When create new class using prototype ,people used to use this manner:
>
> > >> var Person = Class.create();
> > >> Person.prototype = {
> > >>    initialize: function(name) {
> > >>      this.name = name;
> > >>    }
> > >>    printName: function() {
> > >>      alert(this.name);
> > >>    }
> > >> }
>
> > >> However I can not see the advantage of this manner,since it is very
> > >> readable when use the native javascript:
>
> > >> function Person(name) {
> > >>     this.name = name;
> > >> }
> > >> Person.prototype = {
> > >>     printName: function() {
> > >>         alert(this.name);
> > >>     }
> > >> }
>
> > >> Anyone can tell me why?
>
> > >> --
> > >> You received this message because you are subscribed to the Google Groups
> > >> "Prototype & script.aculo.us" group.
> > >> To post to this group, send email to
> > >> prototype-scriptaculous@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> > >> prototype-scriptaculous+unsubscr...@googlegroups.com.
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
> > >  --
> > > You received this message because you are subscribed to the Google Groups
> > > "Prototype & script.aculo.us" group.
> > > To post to this group, send email to
> > > prototype-scriptaculous@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > prototype-scriptaculous+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to