The keyword 'this' inside your styles-object relates to the styles-
object himself and not to your class where your options are defined.
Every { } is a new object with own properties, functions and 'this'.

Following should work:
myFunc: function() {
    var w = this.options.width;
    var h = this.options.height;
    this.myDiv = new Element('div', {
        styles: {
            'width': w + 'px',
            'height': h + 'px'
        }
    });
}

Regards
VuuRWerK ;)

On 25 Okt., 13:19, websam <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I have created a class with som default options :
>
> var myClass = new Class({
>         Implements: [Options, Events],
>
>         options: {
>                 width: 600,
>                 height: 400
>         },
>
>         initialize: function(options){
>                 this.setOptions(options);
>         },
>
>         myFunc: function(){
>                 this.myDiv = new Element('div', {
>                         styles: {
>                                 'width': this.options.width + 'px',
>                                 'height': this.options.height + 'px'
>                         }
>                 });
>         }
>
> });
>
> This is just an example but when i do this.options.width/
> this.options.height on the new element, without setting the options
> when i call the class, the width/height is undefined. What am i doing
> wrong here ?

Reply via email to