FWIW, you also seem to have a frequent typo where you accidentally
drop the "e" on "Mouse":

These don't have the "e":

>         this.e.observe('mouseover', this.onMousOver);
>         this.e.observe('mouseout', this.onMousOut);

But this does:

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

So the second observe line above will fail.  The first one works
because you've dropped the "e" in both the observe call *and* the
function definition.

About a month ago I blogged about the "this" thing, might be useful:
http://blog.niftysnippets.org/2008/04/you-must-remember-this.html

Hope this helps,
--
T.J. Crowder
tj / crowder software / com

On May 2, 6:07 pm, Andreas Bachmann <[EMAIL PROTECTED]> wrote:
> 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