I'm sorry - I've found the solution: function extendWithInstances(theClass){ Object.exctend(theClass, function(){ var instances = [], pubs = {}; ...... }()); }
...... extendWithInstances(Class1); extendWithInstances(Class2); On 28 май, 20:11, buda <www...@pochta.ru> wrote: > I missed to write at the end of module definition write string: > > return pubs; > > On 28 май, 20:09, buda <www...@pochta.ru> wrote: > > > > > > > > > I use to extend class with static members but in a resul I extend > > clsses every time with the same module - but I neet the very time the > > new copy of it > > I need that every class could trace theirs instances > > > var module = (function(){ > > var instances = [], pubs = {}; > > > pubs.addInstance = addInstance; > > function addInstance(inst){ instances.push(inst); } > > > pubs.removeInstance = removeInstance; > > function removeInstance(inst){ instances = > > $A(instances).without(inst); } > > > function getInstances() {return $A(instances); } > > > }()); > > > var Class1 = Class.create({...}), Class2 = Class.create({...}); > > Object.extend(Class1, module); Object.extend(Class2, module)l > > var c1 = new Class1, c2 = new Class2; > > > after creating c1 and c2 in Firebug we could see that every object > > references the same module, so Class1 and Class2 have instances array > > with two elements - but I need to have one > > > If I extend every Class not with module but with explicity defined > > block - everythig works fine? but it's require typing the same every > > time! -- 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-scriptaculous@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.