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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -