Hi

I'm new to prototype and have some problems creating a class...
really!!
I'm using script.aculo.us too, but it's not a problem... rightnow ;)

My code:

var ImageButton = Class.create({
    initialize: function(e) {
        this.e = e;
        this.e.observe('mouseover', this.onMousOver);
        this.e.observe('mouseout', this.onMousOut);
    },

    onMousOver: function() {
        this.fadeIn();
    },

    onMouseOut: function() {
        this.fadeOut();
    },

    fadeIn: function() {
        new Effect.Fade(e, { duration: 1 });
    },

    fadeOut: function() {
        new Effect.Appear(e, { duration: 1, from: 1.0, to: 1.0 });
    }
});

document.observe('dom:loaded' , function() {
    var previous = new ImageButton($('previous'));
    var next    = new ImageButton($('next'));
});

--> Firebug result: this.fadeIn is not a function

The same code but shorter:

var ImageButton = Class.create({
    initialize: function(e) {
        this.e = e;
        this.e.observe('mouseover', this.fadeIn);
        this.e.observe('mouseout', this.fadeOut);
    },

    fadeIn: function() {
        new Effect.Fade(e, { duration: 1 });
    },

    fadeOut: function() {
        new Effect.Appear(e, { duration: 1, from: 1.0, to: 1.0 });
    }
});

document.observe('dom:loaded' , function() {
    var previous = new ImageButton($('previous'));
    var next    = new ImageButton($('next'));
});

--> Firebug result: e is not defined

Any advice to get to work?

--~--~---------~--~----~------------~-------~--~----~
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