我正在使用dojox / mobile / Accordion并添加了一些窗格。
我可以在窗格(ContentPane)或Accordion上设置一个属性,以便在添加窗格时添加它们不会折叠吗?
<div data-dojo-type="dojox/mobile/Accordion" data-dojo-props='singleOpen:false, iconBase:"images/icons16.png"'>
<div data-dojo-type="dojox/mobile/ContentPane"
data-dojo-props='label:"External Content1", iconPos1:"16,32,16,16", href:"data/fragment1.html"'>
</div>
<div data-dojo-type="dojox/mobile/ContentPane"
data-dojo-props='label:"External Content2", iconPos1:"16,32,16,16", href:"data/fragment2.html"'>
</div>
<div data-dojo-type="dojox/mobile/ContentPane"
data-dojo-props='label:"External Content3", iconPos1:"16,32,16,16", href:"data/fragment3.html"'>
</div>
<div data-dojo-type="dojox/mobile/ContentPane"
data-dojo-props='label:"External Content4", iconPos1:"16,32,16,16", href:"data/fragment4.html"'>
</div>
</div>
由于
答案 0 :(得分:1)
您可以将the selected
parameter用于您的子窗格。见this fiddle for an example;您只需将selected: true
添加到data-dojo-props
属性或您传递给子窗口小部件构造函数的属性(如果以编程方式执行):
<div data-dojo-type="dojox/mobile/ContentPane"
data-dojo-props="label: 'External Content1',
iconPos1: '16,32,16,16',
href: 'data/fragment1.html',
selected: true">
</div>
require([
"dojox/mobile/Accordion",
"dojox/mobile/ContentPane",
"dojox/mobile/parser",
"dojox/mobile",
], function(Accordion, ContentPane) {
// ...
var p1 = new ContentPane({
label: 'External Content1',
iconPos1: '16,32,16,16',
href: 'data/fragment1.html',
selected: true
});
// ...
});
答案 1 :(得分:1)
以编程方式添加内容窗格时,您可以设置selected:true
来初始化它们
var pane = new ContentPane({
label: "Added Content",
selected:true,
content: "My Content"
});
accordion.byId("testAccordion").addChild(pane2);
请注意,这仅适用于编程方法。声明性地为多个元素设置selected:true
data-dojo-props
不起作用(目前为1.10)