基本上,它是这样的。我有一个非常结构化的 dojo 应用程序,使用 dojo 样板项目/模板(来自 Github)。我几乎完成了所有不同的模块以使我的应用程序成为它的样子(它有点像 cms)。因此,它是一个在某个区域动态呈现内容的单页应用程序。
我的 EntryPoint.html 看起来像这样:
<div style="height:100%;">
<div
data-dojo-type="dijit.layout.BorderContainer"
data-dojo-attach-point = "appLayout"
data-dojo-props="design: 'headline'"
style="height:100%;">
<div
class="centerPanel"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'center'">
<button data-dojo-attach-point ="testButton" type="button" disabled="disabled">Click Me!</button>
<div id="placeholder"></div>
</div>
<div
class="edgePanel"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'top'">Header content (top)
<span class="test"></span>
</div>
<div
id="leftCol" class="edgePanel"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'left', splitter: true">
<div id="administrationMenu" class="administrationMenu">
<div class="administrationTitle"> Administration </div>
<ul>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/user.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Users </a></li>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/email.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Emails </a></li>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/tools.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Settings </a></li>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/graph.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Logs </a></li>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/faq.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Help </a></li>
</ul>
</div>
<div id="toolsMenu" class="toolsMenu">
<div class="toolsTitle"> Managing tools </div>
<ul>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/donwload.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Resources </a></li>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/play.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Playlists </a></li>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/clock.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Agenda </a></li>
<li><img border="0" src="file:///C:/Users/Dev 2/Desktop/mpact-dojo-boilerplate/src/app/resources/img/silver-gray/monitor.png" alt="Pulpit rock" width="24" height="24"/><a href="#"> Stations </a></li>
</ul>
</div>
</div>
</div>
</div>
*我知道,我知道我的图像应该在 css 中,但我不是真正的设计师,我真的不喜欢创建/调整界面。
我的 EntryPoint.js:
define([
"dojo/_base/declare",
"dijit/_Widget",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"./ui/layout/GridLayout",
"dojo/text!./ui/templates/EntryPoint.html",
"dijit/layout/BorderContainer",
"dijit/layout/TabContainer",
"dijit/layout/ContentPane"
], function(
declare,
_Widget,
_TemplatedMixin,
_WidgetsInTemplateMixin,
GridLayout,
template
){
return declare([_Widget, _TemplatedMixin, _WidgetsInTemplateMixin], {
templateString: template,
constructor: function() {
},
postCreate: function() {
//var gridLayout = new GridLayout({}, "placeholder");
//gridLayout.placeAt("placeholder");
}
});
});
好的,所以我希望基本上能够点击我的各种列表(AdministrationMenu和toolsMenu)。因此,我的内容在centerPanel中加载/呈现。另外,我想在 url 中有我的点击项目。
用例场景:当我第一次加载我的应用程序时,它会加载主页。然后,如果我单击我的菜单项(例如设置),它会加载我的设置页面。并且 url 会变成这样: www.myapp.com/settings 。
谢谢你。
可能的解决方案:对于每个菜单,使用 data-dojo-attach-point 并指定一个名称。对每个使用 dojo.query("").connect 并从我的自定义代码(例如 new SettingsPage )创建一个实例并将其呈现在我的 centerPanel ...