Dojo instances of same widgets are not saparated -


i have built dojo widget creating list entering values. widget code is: define(["dojo/_base/declare", "dijit/_widgetbase", "dijit/_templatedmixin", 'dojo/text!apps/orders/templates/multiaddlist.html', "dojo/dom", "dojo/on", "dojo/dom-construct", "dojo/dom-class", "dojo/query", "dijit/focus"],

function (declare, widgetbase, templatedmixin, html, dom, on, domconstruct, domclass, query, focusutil) {      return declare([widgetbase, templatedmixin], {          templatestring: html,          postcreate: function () {             this.inherited(arguments);             var = this;         },          _checkifenter: function (e) {             if (e.which == 13) {                 this._adduser();             }         },          _adduser: function () {             domclass.remove(this.uladded, "hidden");             var texttoadd = this.usertexttoadd.value;             var li = domconstruct.create("li", {}, this.uladded);             domconstruct.create("span", {innerhtml: texttoadd}, li);             var spanx = domconstruct.create("span", {class: 'icon-x right'}, li);             this.itemsarray.push(texttoadd);             this.usertexttoadd.value = "";             focusutil.focus(this.usertexttoadd);             var = this;             on(spanx, "click", function () {                 domconstruct.destroy(li);                 that.itemsarray.splice(that.itemsarray.indexof(texttoadd), 1);                 if (that.itemsarray.length == 0) {                     domclass.add(that.uladded, "hidden");                 }             });         },          itemsarray: []      }); }); 

it ok. - when instantiate twice on same dialog this:

alloweddomains = new multiaddlist(); alloweddomains.placeat(dom.byid('alloweddomains'), 0); pdlemails = new multiaddlist(); pdlemails.placeat(dom.byid('pdlemails'), 0); 

and asking alloweddomains.itemsarray() or pdlemails.itemsarray() - same list (as if same instance) - althought in ui presentation - adds list items separately , correctly.

obviously, doing wrong although followed dojo examples.

does know should in order make work?

thanks

when make dojo class using declare, object , array members static, meaning shared across instances, suggest doing itemsarray: null , this.itemsarray = [] in constructor or postcreate somewhere.

everything else looks fine, although have preference using hitch, solution fine.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -