javascript - dynamically create a div and combobox, and put combobox in the div using Dojo -
i want create div , combobox
dynamically, put combobox
in div. please see codes below. when run code, threw failed execute 'appendchild' on 'node': parameter 1 not of type 'node'.(…) "typeerror: failed execute 'appendchild' on 'node': parameter 1 not of type 'node'.
what correct way place combobox
in div?
var combobox = new combobox({ name: "state" }); combobox.set('style', {width: '100%', height: '35px', fontsize: '30px'}); var comboboxdiv = domconstruct.create("div"); comboboxdiv.id = "state"; domconstruct.place(combobox, comboboxdiv);
you error because domconstruct
handle dom
nodes, , trying use object, but, can still use it, need pass combobox domnode
domconstruct.place(combobox.domnode, comboboxdiv);
domnode
attach point widgets have, reference root template of widget.
also, note in code, creating div using domconstruct
, but, not placing div in dom
. this:
var comboboxdiv = domconstruct.create("div"); domconstruct.place(comboboxdiv, "someid");//or node, attach point
take domconstruct documentation.
another way place widget in dom, using placeat
function.
var comboboxdiv = domconstruct.create("div"); var mycombobox = new combobox({ name: "state" }); mycombobox.placeat(comboboxdiv);
or, passing second argument constructor can string( id of en element in dome) or node.
var comboboxdiv = domconstruct.create("div"); var mycombobox = new combobox({ name: "state" }, comboboxdiv);
Comments
Post a Comment