以编程方式打开 Dijit AccordionContainer 内的窗格的最佳方法是什么

发布于 2024-07-29 04:23:22 字数 663 浏览 10 评论 0原文

我正在尝试打开& 以编程方式关闭折叠面板。 这是我的代码的简化版本。 即使我将第一个窗格的选择设置为 false,并将第二个窗格的选择设置为 true,但在浏览器 (FF3) 上加载时,只有第一个窗格会打开。

var accordionContainer = new dijit.layout.AccordionContainer().placeAt("test");
var accordPane = new dijit.layout.ContentPane({"title": "test", "content":"hello"});
var accordPane2 = new dijit.layout.ContentPane({"title": "test1", "content":"hello1"});
accordionContainer.addChild(accordPane);
accordionContainer.addChild(accordPane2, 1);
accordPane.startup();
accordPane2.startup();
//accordionContainer.selectChild(accordPane2);
accordionContainer.startup();
accordPane.selected = false;
accordPane2.selected = true;

I am trying open & close accordion panes programatically. Here is the simplified version of my code. Even though I set the first pane's selected to false and and second pane's selected to true, only the first pane opens when it loads on the browser (FF3).

var accordionContainer = new dijit.layout.AccordionContainer().placeAt("test");
var accordPane = new dijit.layout.ContentPane({"title": "test", "content":"hello"});
var accordPane2 = new dijit.layout.ContentPane({"title": "test1", "content":"hello1"});
accordionContainer.addChild(accordPane);
accordionContainer.addChild(accordPane2, 1);
accordPane.startup();
accordPane2.startup();
//accordionContainer.selectChild(accordPane2);
accordionContainer.startup();
accordPane.selected = false;
accordPane2.selected = true;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青朷 2024-08-05 04:23:22

你可以这样做:

accordionContainer.selectChild( accordPane2 );

假设你使用的是dojo 1.3。

dijit.layout.AccordionContainerdijit.layout.StackContainer 的子类,它定义了 selectChild

我设置了一个演示页面,您可以在其中看到此代码的实际运行

如果您正在调用selectChild启动之前,这可能会导致您看到的错误,因为小部件未处于“完整”状态。 (抱歉,在我发布原始答案之前错过了comnetout代码)

You can do it like this:

accordionContainer.selectChild( accordPane2 );

Assuming you are using dojo 1.3.

dijit.layout.AccordionContainer is a subclass of dijit.layout.StackContainer, which has selectChild defined.

I set up a demo page where you can see this code in action

If you were calling selectChild before startup, that could cause the error you were seeing since the widget wasn't in a 'complete' state. (Sorry, missed the commneted out code before I posted original answer)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文