EricGoogle wrote:
> Hello kangax,
>
> I am trying to keep "state" information in the correspoding elements
> themselves rather that having each element have a "brother object"
> that keeps it's state information.
> I can't figure out how to do that with a method as opposed to a
> property.
>
> I can think of many useful reasons for having both properties and
> methods for objects in a language and this is a good example of how it
> could be useful.
>
> thanks for the feedback,
>
> -Eric
>   
Attaching custom properties to elements is quite useful, but you don't 
need to attach a property to Element.prototype in order to do it. You 
should probably attach properties something like this:

$$('.brothers').invoke('writeAttribute', '__isBrother', true);

// OR
$$('.celebrity').each(function(element) {
  var brother = element.next();
  element.writeAttribute('__brother', brother);
});

// OR
$$('.celebrity').each(function(element) {
  var brotherId = element.next().identify();
  element.writeAttribute('__brotherId', brotherId);
});

If that isn't helpful, maybe you could tell us more about what your 
application needs to do.

- Ken Snyder

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