Hi Tashos. This is just how JavaScript works. An object (map) is a "reference type' in JavaScript. That means that regardless of how many variables are assigned that same value, they'll all get a reference to the one and only actual object. So when you create your object in the *members* section like this:
... members : { x : {} }, ... you are, at that very moment, creating the empty object and stating that as each instance of the object is created, the x member should "point to" (reference, in JavaScript parlance) that one single object. Your solution of initializing the member in the constructor is the correct one. Cheers, Derrell On Wed, Dec 16, 2015 at 10:53 AM tashos <tmitu...@balkantel.net> wrote: > Hi, > We are using qooxdoo for development and I experienced a bug. I have > declared a member that is pointing to a object and edit that member in > the constructor of the class. When I create two or more instances of > said class the member always points to the last created instance. If I > assign the member to "this" like "this.member = {};" then it works like > it is expected to. Can you give me a suggestion or a reason as to why > this is happening? > > PS.: The declaration in members goes as follows: members: > { > member: {}, > funcUsingMember: function () { > // Some business logic > > return this.member.key; > } > } > > > > ------------------------------------------------------------------------------ > _______________________________________________ > qooxdoo-devel mailing list > qooxdoo-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel >
------------------------------------------------------------------------------
_______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel