Dojox手风琴 - 手风琴上添加了未折叠的窗格

时间:2014-09-15 18:10:54

标签: dojo

我正在使用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>

由于

2 个答案:

答案 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)

JSFiddle