I've run into a strange scenario using D3 to create a simple form-like experience.
The flow goes something like this...
1) Create the element using D3, with a default value
2) Bind a function to a button to read the value of this text area and do stuff
var content = d3.select('#content');
content.append('div')
.append("input")
.attr("type", "text")
.attr("id", "textinput")
.attr("size", "40")
.attr("value","Default Text");
content.append('div')
.html('Get contents...')
.on("click", function () {
console.log("D3 Selection: " + d3.select("#textinput").attr('value'));
console.log("DOM Selection: " + document.getElementById("textinput").value);
});
The value of the DOM selection is whatever has been entered by the user, and the value of the D3 selection is always "Default Text", no matter what the user has entered:
D3 Selection: Default Text
DOM Selection: I typed something
What am I missing (aside from the obvious knowledge, skill etc. - in my defense I mostly just do this for fun)? Is the D3 selector not supposed to function in this way?
Dave