Hi,
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);
if(myInstance.isB())...
=> isB is undefined
I also tried the opposite approach with:
myInstance = Object.extend(myJsonObject,MyClass.prototype)
if(myInstance.isB())...
=> isB is undefined
What is the correct way of achieving this ?
Eric
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---