在Dijit AccordionContainer中编程打开窗格的最佳方式是什么? [英] Whats the best way to programatically open a pane inside Dijit AccordionContainer

查看:159
本文介绍了在Dijit AccordionContainer中编程打开窗格的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开放&以手风琴格式编程。这是我的代码的简化版本。即使我将所选的第一个窗格设置为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;


解决方案

你可以这样做:

  accordionContainer.selectChild(accordPane2); 

假设您正在使用dojo 1.3。



dijit.layout.AccordionContainer dijit.layout.StackContainer 的子类,它具有 selectChild 定义。



我设置了一个演示页面,您可以在此处看到此代码



如果您在之前调用 selectChild c $ c> startup ,这可能会导致您看到的错误,因为窗口小部件不处于完整状态。 (对不起,在我发布原始答案之前错过了输入的代码)


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;

解决方案

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)

这篇关于在Dijit AccordionContainer中编程打开窗格的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆