Are you using 1.6+ ?
The correct syntax for defining a "class" has changed since 1.5:
var ReadHash = Class.create({
initialize: function(data){
this.data=data;
},
read: function(){
this.data.each(function(pair) {
alert(pair.key + ' = "' + pair.value + '"');
});
}
});
var ReadMyData = Class.create(ReadHash, {
initialize: function(data){
this.data=data;
}
});
var TestReadHash = new ReadMyData($H({ var1: 'foo1', var2: 'foo2' }));
TestReadHash.read(); // works as expected
Hope this helps.
P.S. please, post futher question at support mailing list
http://groups.google.com/group/rubyonrails-spinoffs. This one is
development related.
Best,
kangax
On Jun 7, 9:09 pm, aljvilla <[EMAIL PROTECTED]> wrote:
> I created this function to read a hash,
>
> var ReadHash = Class.create();
> ReadHash.prototyte = {
> initialize: function(data){
> this.data=data;
> },
> read: function(){
> this.data.each(function(pair) {
> alert(pair.key + ' = "' + pair.value + '"');
> });
> }};
>
> var ReadMyData = Class.create();
> ReadMyData.prototype = Object.extend(new ReadHash(),{
> initialize: function(data){
> this.data=data;
> }});
>
> var TestReadHash = new ReadMyData($H({ var1: 'foo1', var2: 'foo2' }));
> TestReadHash.read();
>
> the problem is that it does not recognize the function
> TestReadHash.read ();
> It would be helpful if detected the error and spend 4 hours reviewing
> and not to understand that I am wrong
> thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---