循环遍历我的数组后,我正在构建基于数组对象的多个按钮。但是,我想使用数组中的dojo按钮或dijit按钮动态构建按钮。我怎么能这样做?
这就是我所拥有的:
array.forEach(this.DYNAMIC_FILTER_FORMS, function (entry, i) {
//console.debug(entry, "at index", i);
var button = domConstruct.create("button", {
id: "menuBtn" + i,
class: "menuBtnClass",
"name": entry.menuText,
"value": entry.menuText
}, dom.byId("content"));
button.innerHTML = entry.menuText;
我想要这样的东西,但是来自数组的多个按钮:
// Create a button programmatically:
var myButton = new Button({
label: "Click me!",
onClick: function(){
// Do something:
dom.byId("result1").innerHTML += "Thank you! ";
}
}, "progButtonNode").startup();
答案 0 :(得分:0)
array.forEach(this.DYNAMIC_FILTER_FORMS, function (entry, i) {
var myButton = new Button({
label: entry.menuText,
onClick: function(){ ... }
});
myButton.placeAt("content");
});