Hi Richard, thanks for your reply. With
> The return is something I've been using since May 2008 with all the > releases and updates since then. Do you mean you have used the native prototype-return, or did you alter it, and it still worked? On Dec 16, 6:04 pm, Richard Quadling <rquadl...@gmail.com> wrote: > On 16 December 2010 16:36, Luke <kickingje...@gmail.com> wrote: > > > > > > > Hi, > > > if you define a Class like > > > ---------------------------------- > > var TestClass = Class.create({ > > initialize: function(element) { > > element = $(element); > > this.doFunkyStuffWithElement(element) > > return element; > > }, > > doFunkyStuffWithElement: function(element) { log("funky stuff > > here") } > > }); > > ---------------------------------- > > > and you instantiate that Class > > > var myObject = new TestClass(); > > > is there a way I can change it so (while namespacing my Class-Code so > > Prototype's Class will remain untouched) that instantiation of that > > class will return something different than what Prototype returns (in > > my case a DOM-Object that has been extended with custom Methods)? > > > --- > > Why I want to do this: I'm working on a site where you can create > > really simple webpages by adding, editing, and removing elements on > > your page. To structure my code I make use of prototype's dom- > > extending nature and its way of class-inheritance: > > There is a base class for elements on the page which has methods for > > editing and removing that object and so on. I subclass this base-class > > for specific elements where I implement the specific editing/removing/ > > whatever-code. Now to map my functionality to the elements on the > > page, I extend the DOM-Elements which you can edit/etc with the > > methods and properties of the class, leaving out unnecessary > > constructors etc. > > > But it is always a little annoying to extend an object with a class, > > and then fetch that object again to work with it: > > > ---------------------------------- > > new EditablePicture($('the_element_I_extend')); > > var my_element = $('the_element_I_extend'); > > my_element.do_something(); > > ---------------------------------- > > > it would be nice to be able to do something like this: > > > ---------------------------------- > > var my_element = new EditablePicture($('the_element_I_extend')); > > my_element.do_something(); > > ---------------------------------- > > > Is that kind of stuff even possible? > > > Thank you > > Lukas > > > -- > > You received this message because you are subscribed to the Google Groups > > "Prototype & script.aculo.us" group. > > To post to this group, send email to > > prototype-scriptacul...@googlegroups.com. > > To unsubscribe from this group, send email to > > prototype-scriptaculous+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/prototype-scriptaculous?hl=en. > > Yep - I think so. Look at around line 80 of prototype.js > > function klass() { > return this.initialize.apply(this, arguments); > } > > The return is something I've been using since May 2008 with all the > releases and updates since then. > > I've not had any issues with my code or with scripty with it. > > -- > Richard Quadling > Twitter : EE : Zend > @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.