Hey there, having a very frustrating problem.
Here is my sheetCell class.
For some reason, this.obj and this.objVal have the same instance in different Class instances.Code:sheetCell = function(options) { for(var x in options) this[x] = options[x]; if(this.headerNum != -1) { var itm = this.parent.parent.header[this.headerNum]; this.objVal = document.createElement("input"); this.objVal.type = "hidden"; this.objVal.name = this.parent.parent.name + "["+this.parent.rowNum+"]["+itm.name+"]"; switch(itm.type) { case 'text': this.obj = document.createElement("input"); this.obj.setAttribute("data-role","none"); this.obj.type = "text"; this.objVal.value = this.obj.value = itm.value; var self = this; this.obj.onchange = function() { self.objVal.value = self.obj.value; } break; case 'func': this.obj = itm.func(itm, this, "create"); break; } } }; sheetCell.prototype = {obj : null, objVal : null, parent : null, cellNum :-1, headerNum: -1, value : function(val) { if(typeof(val) == "undefined") return this.objVal.value; else { this.objVal.value = val; } }, display : function(val) { if(typeof(val) == "undefined") return this.obj.value; else this.obj.value = val; }, paint : function(cell) { cell.appendChild(this.objVal); cell.appendChild(this.obj); if(this.parent.parent.header[this.headerNum].hidden) { cell.style.display = "none"; } } }
I have tested to see if cellNum, headerNum and parent.rowNum have different values, and they do.
There is only one time where new sheetCell is being called, (It is being called in the code order shown below)
So, does anyone have any idea on how to fix this before I go insane? Hehe. Thank you very muchCode:jqmSheet.prototype.proccessRows = function(data) { for(var x in data) { if(data[x].deleted == "0") { var aRow = this.addRow({noUpdate:true}); var aCell = null; for(var y in data[x]) { if(aCell = aRow.findCell(y)) { aCell.value(data[x][y]); aCell.display(data[x][y]); } } if(this.updateRow) { for(var x in this.header) if(this.header[x].type == "func") this.header[x].func(this.header[x],aRow.findCell(this.header[x].name),"update"); this.updateRow(aRow); } } else { var h = document.createElement("input"); h.type = "hidden"; h.name = this.name + "["+x+"][deleted]"; h.value = data[x].deleted; h.setAttribute("rowNum",x); this.invisEle.appendChild(h); } } for(var x in this.row) { for(var y in this.row[x].cell) { alert(x + "::" + y + "::" + this.row[x].cell[y].objVal.name); } } this.paint(); }; jqmSheet.prototype.addRow = function(options) { if(typeof(options) == "undefined") options = {}; ++this.rowCount; options['parent'] = this; options['rowNum'] = this.rowCount; this.row[this.rowCount] = new this.sheetRow(options); if(!options['noUpdate']) if(this.updateRow) this.updateRow(this.row[this.rowCount]); return this.row[this.rowCount]; }; jqmSheet.prototype.sheetRow = function(options) { for(var x in options) this[x] = options[x]; //on creation look through the header and add all the cells. for(var x in this.parent.header) { this.addCell({"headerNum":x}); }; }; jqmSheet.prototype.sheetRow.prototype.addCell = function(options) { //on creation if(typeof(options) == "undefined") options = {}; options['parent'] = this; ++this.cellCount; options['cellNum'] = this.cellCount; options['name'] = ''; this.cell[this.cellCount] = new sheetCell(options); return this.cell[this.cellCount]; }
Also, if anyone knows of an existing javascript class that lets you do data-entry I'd just use that instead.


Reply With Quote
Bookmarks