Had to prove to myself that was even possible, I've got it done although I know it could be written a bit smoother, it gets the job done for the example. Seems like too much work to get such a simple task accomplished but it does allow for a nice private variable, getter/setter pattern.
var ref = function(){ var state = 0; this.set = function(incoming){ state = incoming;}; this.get = function(){ return state; }; } Element.addMethods("DIV", { stateReference : function(ele){ if(!ele.stateReferenceGetter) return ele.stateReferenceGetter = new ref(); else return ele.stateReferenceGetter; } }); To check out the demo in action, http://positionabsolute.net/projects/javascript/AddElementGetter/ Demo goes down in Firebug basically, speaking of which today is FF 3 Download Day, show some support!! -- Matt Foster Ajax Engineer Nth Penguin, LLC http://www.nthpenguin.com On Jun 17, 2:55 pm, Matt Foster <[EMAIL PROTECTED]> wrote: > Could the method be used as a "getter" that would return the reference > to the proper state? > > -- > Matt Foster > Ajax Engineer > Nth Penguin, LLChttp://www.nthpenguin.com > > On Jun 17, 2:24 pm, EricGoogle <[EMAIL PROTECTED]> 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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---