Hi again,
I'm working on a little project that lets users create (very) simple
websites. On his site the user can add sections (like a text or a big image
or a video) one below the other. Each section can be edited by clicking a
link underneath the section. So to structure my code, and give me some
convenience for later work, I copied and modified prototype's
class-implementation so that a class created with my implementation can
[optionally] be passed a DOM-object as parameter, which will be extended
with a set of methods and properties of the class. That means I can create a
class for a section and instantiate it passing it a section-DOM-Object. That
section-object has all functions it needs to have to be edited right
attached to it.
That allows me to structure my code in a very OOP-like manner, seeing
DOM-Objects as instances of my classes. Also I can still query the DOM-Tree
the Prototype way and perform actions on it (like
$$('.section').first.edit()).
One trap I of course had to work around is name-conflicts, because I'm
extending with up to 10 methods and properties. I just prefixed my names
with rb (like $$('.section').first.rbEdit()). It's ugly, but it works.
What do you think of such a structure? Sounds ok? Sounds problematic?
All feedback is very appreciated :)
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.