Thanks for your reply T.J.!

I did used Class instead of class. This was a typo when I posted :o)

You're right, it should have work the way I did it... and it actually
did work this way...
...except that due to a mistake in my events handling, my new thing
value was overridden by some obsolete part of code just after being
converted into a class instance :o(
And since it was overridden by the raw JSON object value, I stupidly
assumed that the casting didn't work.

At least, I now know what is the "state of the art" way of getting a
class instance through Ajax ;o)

Thanks again!
Eric

On Aug 12, 10:49 am, "T.J. Crowder" <[email protected]> wrote:
> Hi,
>
> That should work.  I notice that you have "class.Create" rather than
> "Class.create"; I assume that's just an error in the note and that the
> actual code uses Class.create?  Because if not, that's your problem.
>
> > if(myInstance.isB())...
>
> > => isB is undefined
>
> That indicates there's a different problem.  isB should be defined
> regardless, you defined it in your class definition.  If the
> Object.extend thing weren't working, it should *return* undefined, but
> not *be* undefined.
>
> FWIW, this works:
> * * * * (also athttp://pastie.org/581050)
> // Defining
> var Thing = Class.create({
>     initialize: function(src)
>     {
>         if (src) {
>             Object.extend(this, src);
>         }
>     },
>
>     isB: function()
>     {
>         return this.b;
>     }
>
> });
>
> // Using:
> var t;
> t = new Thing({"b": true});
> alert("t.isB() ? " + t.isB());
> * * * *
>
> HTH,
> --
> T.J. Crowder
> tj / crowder software / com
> Independent Software Engineer, consulting services available

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to