javascript - Dojo: adding a button dynamically -
i'm trying add dijit button node failing
error: failed execute 'appendchild' on 'node': new child element null.
the code is
var output = dom.byid(this.baseclass + 'displayvalues'); var btndelete = new button({ label: "delete" }, "btndelete"); btndelete.startup(); domconstruct.place(btndelete, output);
the output element valid can add bunch of span tags if want same sort of code
i can add buttons kind of code
var node = domconstruct.todom('<li>' + name + '|' + value + '<button type=\"button\" onclick=\"this._removeitem(\'' + name + '\');\">x</button></li>');
but in case can't find on click method this, parent or no modifier. in case document says not kind of thing because of memeory leaks
does have pointers might going wrong.
many help
second argument button constructor may either id of html element, or domnode object.
this how use second option, dynamically created nodes.
define(["dojo", "dojo/dom", "dojo/dom-style", "dojo/dom-class", "dojo/dom-construct", "dojo/query", function(dojo, dom, domstyle, domclass, domconstruct, query) { var buttons = dom.byid('my-buttons'); var buttonnode = domconstruct.todom('<button type="button" class="button delete-button"></button>') buttons.appendchild(buttonnode) var button = new button({label: "delete" }, buttonnode); })
Comments
Post a Comment