I make some Ajax calls to fetch objects from my server, and I would
like those object to be instance of some class.
I just cannot find a way to achieve this...

Here is what I've tried so far :

var MyClass = class.Create({
  initialize: function(src) {
    if(src) Object.extend(this,src);
  isB: function() { return this.b;}

var myJsonObject = {"a":0, "b":true}; // xrh.responseJSON

myInstance = new MyClass(myJsonObject);


=> isB is undefined

I also tried the opposite approach with:
myInstance = Object.extend(myJsonObject,MyClass.prototype)

=> isB is undefined

What is the correct way of achieving this ?

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 
For more options, visit this group at 

Reply via email to