Please give us a URL so that we can see what you've done. That way
it'll be much easier to help.
Cheers,
Andrew
On Feb 14, 3:20 pm, kojilab <[EMAIL PROTECTED]> wrote:
> Actually the bind throws an error in Firebug
> this.hide has no properties
>
> On Feb 14, 10:37 am, kangax <[EMAIL PROTECTED]> wrote:
>
> > hide method needs to be bound to an instance of your class when using
> > it as an event handler.
>
> > ...
> > this.element1.observe('click', this.hide.bind(this));
> > ...
>
> > - kangax
>
> > On Feb 14, 12:27 pm, kojilab <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I have a class with DOM elements as properties. I want to bind events
> > > within the class to the ements. Unfortunately I am getting an error
> > > telling me those properties are not defined. Here's an simplfied
> > > example of what I'm trying to achieve.
>
> > > var MyClass=Class.create()
> > > MyClass.prototye = {
> > > initialize: function(element1, element2){
> > > this.element1=element1;
> > > this.element2=element2;
> > > this.element1.observe('click',this.hide);
> > > },
>
> > > hide: function(){
> > > this.element2.hide();
> > > }
>
> > > Thanks for your help
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---