我正在尝试创建一个自定义 dojo 小部件,以防止“过渡”到内容窗格。我试图让窗格链接到另一个页面而不是滑动。
我将使用属性 doExpand="false" 示例指定此选项:
<div id="menu">
<div dojoType="AccordionMenu" doLayout="true" class="tundra" style="height: 300px">
<div dojoType="AccordionPane" doExpand="false" title="<p>Home</p>"></div>
<div dojoType="AccordionPane" selected="true" title="<p>Tasks 1</p>">
<ul class="nav">
<li><a href="#">Task 1</a></li>
<li><a href="#">Task 2</a></li>
<li><a href="#">Task 3</a></li>
</ul>
</div>
<div dojoType="AccordionPane" title="<p>Tasks 2</p>">
<ul class="nav">
<li><a href="#">Task 1</a></li>
<li><a href="#">Task 2</a></li>
<li><a href="#">Task 3</a></li>
</ul>
</div>
</div>
</div>
我已经像这样设置了我的自定义小部件:
<script>
dojo.require("dojo.parser");
dojo.require("dijit.Menu");
dojo.require("dijit.MenuSeparator");
dojo.require("dijit.MenuItem");
dojo.require("dijit.PopupMenuItem");
dojo.require("dijit.layout.AccordionContainer");
dojo.ready(function(){
console.log('AccordionMenu loading');
dojo.declare("AccordionMenu",
[dijit.layout.AccordionContainer],
{
postMixInProperties: function(){
console.log('AccordionMenu postMixInProperties');
},
_transition: function(/*dijit._Widget?*/ newWidget, /*dijit._Widget?*/ oldWidget, /*Boolean*/ animate){
if (newWidget.doExpand == true){
this.inherited(arguments);
};
}
});
console.log('AccordionPane loading done');
dojo.declare("AccordionPane",
[dijit.layout.ContentPane],
{
doExpand: true,
postMixInProperties: function(){
console.log('AccordionPane postMixInProperties');
}
});
console.log('AccordionPane loading done');
});
dojo.addOnLoad( function(){
console.log('parse menu');
dojo.parser.parse("menu");
});
</script>
这有点工作,但是当我点击不同的 ContentPane 时,它不会折叠前一个。可能有更好的方法来做到这一点。
这是一个活生生的例子 - http://jsfiddle.net/qPqhK/15/