Hi all,
I have a "Dataset" class which generates a table of hidden HTMLInput Nodes. I am getting a weird problem where if one of my other classes tries to add a row as follows:
Code:
myDataSet.addRow(["firstValue", "secondValue"]);
Then the first value isn't set and so the HTMLInput which is generated has a null value. If I, instead, try to add a row using the same code in the console, it works perfectly.
I then looked at my source for the Dataset class and set a breakpoint just as it creates the input node (context to follow).
Code:
addRow: function(data) {
if($type(data) != "array") {
return false;
}
var index = this.counter;
var set = new Element("fieldset");
this.sets[index] = set;
this.nodes[index] = [];
this.fields.each(function(field, order) {
if(field.ignore) { return; }
var node = new Element("input", {
"type": "hidden",
"name": field.name.replace("__index__", index),
"value": ( (field.sync) ? ( (field.isIndex) ? index : data[order] ) : null )
});
set.adopt(node);
this.nodes[index][order] = node;
}, this);
set.inject(this.rootNode);
this.counter++;
return index;
},
I set my breakpoint where it says "set.adopt(node)". I tried (in the console):
... returned "firstValue" as I expected it would. I then stored the node in "window['testNode']" and tried
Code:
window["testNode"].get("value");
at which point I got a null value. This is really weird, no?
Anyone with any good ideas? I suppose I should add that I'm using Mootools.
Bookmarks