我想在Dojo TabContainer的标签中放置一个复选框。我在这里找到了一个例子:
http://telliott.net/dojoExamples/dojo-checkboxTabExample.html
但是,该示例仅显示html。我想以编程方式执行此操作。这就是我到目前为止所做的:
function(response){
var json_response = JSON.parse(response);
var fields_dict = json_response['fields_dict'];
var names_dict = json_response['names_dict'];
var tc = new TabContainer({
style: "height: 495px; width: 100%;",
tabPosition: "left",
tabStrip: true
}, "report_tab_container");
for(var key in fields_dict) {
var content_string = '';
var fields = fields_dict[key];
for(var field in fields) content_string += '<div>' + fields[field][0] + fields[field][1] + '</div>';
var checkBox = new CheckBox({
name: "checkBox",
value: "agreed",
checked: false,
onChange: function(b){ alert('onChange called with parameter = ' + b + ', and widget value = ' + this.get('value') ); }
}).startup();
var tcp = new ContentPane({
//title: names_dict[key],
title: checkBox,
content: content_string
});
tc.addChild(tcp);
}
tc.startup();
tc.resize();
},
然而,这不起作用。当我加载页面时,TabContainer不会显示。如果我将ContentPane的标题设置为我的复选框以外的其他内容,则可以正常工作。
我做错了什么,如何让复选框出现在TabContainer标题中?
答案 0 :(得分:1)
这是有用的:
cb.placeAt('report_tab_container_tablist_dijit_layout_ContentPane_'+ i.toString(), "first");
答案 1 :(得分:0)
我在这里盲目地这样做,但是将链接上的示例与代码进行比较,我会说,在tc.addChild(tcp)之前添加:
checkBox.placeAt(tcp.domNode, "first");