Gday Luca,

Maybe try this instead?

initialize:function(arg1,arg2){
        this.prop1 = arg1;
        this.prop2 = arg2;

        //assign method1 to methodProp
        this.methodProp = this.method1;
},


Ive added "this" infront of the assignment of this.methodProp.

Keith


Luca wrote:
> Hi, I've got a little problem. I'd like to assign an instance method
> to an instance property inside a class created via prototype.js. Below
> there's an example that doesn't work. I've made a lot of tests, but I
> cannot figure out the problem. Any idea?
>
> ----------------
>
> var myClass = Class.create();
>
> myClass.prototype = {
>       initialize:function(arg1,arg2){
>               this.prop1 = arg1;
>               this.prop2 = arg2;
>
>               //assign method1 to methodProp
>               this.methodProp = method1;
>                 //if I alert this.methodProp here, I have the function
> code but...***
>       },
>
>       method1:function(){
>               [code..]
>       },
>
>       method2:function(){
>               //use method 1 via this.methodProp
>                 //*** If I alert this.methodProp here, I get
> undefined....
>               this.methodProp();
>       }
> }
>
> ----------------
>
>
> >
>   


-- 
MindVision Interactive

Ph: (08) 8212 9544
Fax: (08) 8212 9644

E-Mail: [EMAIL PROTECTED]
Web: www.mindvision.com.au


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to