Reputation: 85
I'm struggling dynamically creating a dijit.form.DateTextBox
and then adding it to an existing document. I've tried several things, first of which is to dynamically create the field via new dijit.form.DateTextBox
and then adding it via domConstruct
. With this method, I end up getting
"Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'."
.
When I try to dynamically create it with a string that evaluates to what I would use if I was declaratively creating it, I end up with a simple text box.
I was hopeful that the HTML 5 date would work, but it doesn't seem they've improved that a single bit since the moment they came up with the idea.
Here's the code I'm using. The commented version is the one that attempts to create it declaratively, which ends up as only a simple text field, and not a DateTextBox
var startDateField = new dijit.form.DateTextBox({ name: startDateID, class: "dateField",
value: startDate, onchange: "setstartDate(this.value)"}, startDateID);
//var startDateField = '<input id="' + startDateID + '" data-dojo-type="dijit.form.DateTextField" name="' + startDateID + '" class="dateField" ' +
// 'value="' + startDate + '" required onChange="setstartDate(this.value)"/>';
var startDateField = domConstruct.place(startDate, startDateLabel, "after");
Upvotes: 0
Views: 619
Reputation: 3568
You have to use placeAt
when it comes to widgets:
var startDateField = new dijit.form.DateTextBox({ name: startDateID, class: "dateField", value: startDate, onchange: "setstartDate(this.value)"}, startDateID);
startDateField.placeAt(startDateLabel, "after");
Upvotes: 1