基本上我有一个JSP页面,在单击按钮时,它应该创建一个新的选项卡,其中href设置为$ {submission.id}变量。但是,单击该按钮不会生成任何选项卡。我已经尝试过查看dojo教程和阅读文档,但我对自己的错误感到迷茫。
<script>
dojoConfig = {
async : true,
parseOnLoad : true
}
</script>
<script src="js/dojo/dojo.js"></script>
<div id="tabPanel" data-dojo-type="dijit/layout/TabContainer" style="width: 100%; height: 100%;" data-dojo-props="region: 'center'">
<div data-dojo-type="dijit/layout/ContentPane" title="Home" data-dojo-props="selected: true">
<button data-dojo-type="dijit/form/Button" type="button"
onclick="registry.byId('tabPanel').addChild(new ContentPane({
title:'test',
closable:true,
href:'submissions/${submission.id}'
}), 6);">Details</button>
</div>
</div>
<script>
require([ //Layout and Menu
"dojo/parser",
"dojo/dom",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/form/Button",
"dojo/domReady!"
], function(parser) {
parser.parse();
});
</script>
答案 0 :(得分:0)
您的网页似乎没有一个ID为tabPanel
的小部件。您的TabContainer具有类 tabPanel
,但您需要为tabPanel
调用设置 id registry.byId
找到它。
答案 1 :(得分:0)
onclick
属性中调用的代码没有对所需模块的引用。
您可以尝试以下方法。
<button data-dojo-type="dijit/form/Button" type="button"
onclick="createTab();">Details</button>
<script>
function createTab(){
require([ //registry and ContenPane
"dijit/registry",
"dijit/layout/ContentPane"
], function(registry,ContentPane) {
registry.byId('tabPanel')
.addChild(new ContentPane({
title:'test',
closable:true,
href:'submissions/${submission.id}'
}),6);
});
}
</script>