[Proto-Scripty] Re: Tying an Element and a custom class together

2009-10-22 Thread Matt Foster
Yeah that'd be great functionality to allow for a much simpler proxy On Oct 19, 9:48 am, Eric lefauv...@gmail.com wrote: Matt, I like your way of doing it, but my concern is that the documented toElement() method seems to be only half implemented. A minor change to the $() function could

[Proto-Scripty] Re: Tying an Element and a custom class together

2009-10-19 Thread Eric
Matt, I like your way of doing it, but my concern is that the documented toElement() method seems to be only half implemented. A minor change to the $() function could make it work completely (see it here: http://pastie.org/660553 ). What do you guys think about this change? Eric On Oct 17,

[Proto-Scripty] Re: Tying an Element and a custom class together

2009-10-16 Thread Eric
Hi, While I agree with T.J. arguments, there are cases when it is nice to have this behavior (DOM element and Plain object in the same object). On of those case is, for example when you're creating a new control class. The way I do it is: - building the DOM element in the class's constructor

[Proto-Scripty] Re: Tying an Element and a custom class together

2009-10-16 Thread Matt Foster
The has a relationship is the only way to go for sure. You could create an ElementProxy class that inherits all the Element methods but just keeps a reference to the actual DOM reference internally. All of the Element.Methods are parameterized so I'm sure there'd be an easy way to delegate the

[Proto-Scripty] Re: Tying an Element and a custom class together

2009-10-16 Thread Matt Foster
Quick and dirty, im sure there are errors but conceptually this would be my approach... var ElementProxy = Class.create({ initialize : function(ele){ this.element = $(ele); this.nodeType =

[Proto-Scripty] Re: Tying an Element and a custom class together

2009-09-10 Thread T.J. Crowder
Hi Andrea, FWIW, I'd say the best practice is: Don't do that, it conflates the model with the view *and* the controller. :-) (MVC is not by any means the only game in town, but the terminology is useful for questions like this.) If you ever want to present the business object in two different