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 at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to