当前位置: 首页 > 知识库问答 >
问题:

Dojo中的动态内容单页应用

贺俊楚
2023-03-14

基本上是这样的。我有一个非常结构化的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,但我不是一个真正的设计师,我真的没有乐趣创建/调整界面。

我的入口点。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");
        }

    });
});

好的,我想基本上能够点击我的各种列表(管理菜单和工具菜单)。因此,我的内容将在centerPanel中加载/渲染。另外,我希望在url中有我的点击项目。

用例场景:当我第一次加载我的应用程序时,它会加载主页。然后,如果我单击我的菜单项(例如设置),它将加载我的设置页面。url会变成这样:www.myapp。com/settings。

谢谢你。

可能的解决方案:对于每个菜单,使用data-dojo附加点和指定的名称。使用dojo.query(")。

共有2个答案

松灿
2023-03-14
匿名用户

您可以使用dojo。back可修改位置栏中的url,并使浏览器后退/前进功能正常工作。

http://dojotoolkit.org/reference-guide/1.7/dojo/back.html

“设置页面”是从服务器加载的html页面还是负责在浏览器上创建页面的dojo小部件?如果它是一个html页面,那么@mschr给出的答案将适用于您。

如果您希望设置页面是一个小部件,那么您可以将中心面板设置为dijit。StackContainer.选择菜单项时,创建适当的子小部件并将其添加到StackContainer中,并对服务器进行后台调用以获取必要的json数据。

http://dojotoolkit.org/reference-guide/1.7/dijit/layout/StackContainer.html

阳昊
2023-03-14

我有一个类似的设置,一个“列表”,将各种小部件加载到contentpane中。底部链接的代码有点复杂,因为它具有加载微调器的功能,在卸载时检查isdirty,并进行大量的请求/垃圾收集。。

最简单的方案是使用dijit。列出您的条目的树,例如json结构,如下所示:

adminJson = { identifier:'url', items: [
     { url: 'admin/user', label: 'user' },
     { url: 'admin/email', label: 'email' }
];

在你的Tree中,'link'this与一个特定的内容窗格--例如中心面板。

tree.on("click", function (item) { // refer to paneRequested
   dijit.byId('centerPanel').set("href", this.model.store.getValue(item, 'url'));
});

<style>
.administrationListTree .dijitTreeNode .iconNode {
  background: url(.....app/resources/img/silver-gray/adminsprites.png) top left no-repeat transparent;
}
.administrationListTree .dijitTreeRow .iconNode.user { background-position: 0 0; }
.administrationListTree .dijitTreeRow .iconNode.email { background-position: -20px 0; }
</style>
<script>
new dijit.Tree({
   getIconClass: function(item, opened) {
      return item.label;
   }
});
</script>

看看https://github.com/mschr/oocms/blob/master/admin/include/application.js对于一些额外的技巧,只需跳过dtopic。发布(“通知/进度/?”)和模块=[?]零件<不过,我有一种感觉,因为您携带的是“管理菜单”名称,所以在卸载PANE之前的操作会很有趣。每个开关将1)调用AbstractController。isDirty或2)实现自定义检查,然后仅在用户允许或没有挂起更改的情况下卸载。

 类似资料:
  • 我们已经为一些静态页面创建了动作和视图,现在要稍微添加一些动态内容,根据所在的页面不同而变化:我们要让标题根据页面的内容变化。改变标题到底算不算真正动态还有争议,这么做能为第 7 章实现的真正动态内容打下基础。 我们的计划是修改首页、“帮助”页面和“关于”页面,让每页显示的标题都不一样。为此,我们要在页面的视图中使用 &lt;title&gt; 标签。大多数浏览器都会在浏览器窗口的顶部显示标题中的

  • 注意:用户界面已经在 Dreamweaver CC 和更高版本中做了简化。因此,您可能在 Dreamweaver CC 和更高版本中找不到本文中描述的一些选项。有关详细信息,请参阅此文章。 关于添加动态内容 定义一个或多个动态内容源后,可以使用这些源向页面中添加动态内容。内容源可以包括记录集中的列、HTML 表单提交的值、服务器对象中包含的值或其它数据。 在 Dreamweaver 中,几乎可以将

  • 我试图刮这个网站:https://ec.europa.eu/research/mariecurieactions/how-to/find-job_en使用Python。 首先,我注意到我感兴趣的表实际上位于以下url:https://ec.europa.eu/assets/eac/msca/jobs/import-jobs_en.htm 然而,请求BS4只给我超文本标记语言的页面源。我假设这是因为

  • 正如我们所知,是绘制的,并且以后对它的更改(在我的例子中,上的新)不会显示/不会更新。当完成时,如何“通知”InfoWindow重新加载它自己?当我把 在中,它创建了一个无限循环,在这个循环中,标记将弹出、开始加载图像、弹出自身等。 我的第二个问题是,在慢速网络连接上(用代码中的5000ms延迟进行模拟),中的将始终显示最后加载的图像,无论该图像是否属于该/。 对如何有效实施这一点有什么建议吗?

  • 问题内容: 我需要从此网站Link中抓取新闻公告。公告似乎是动态生成的。它们不会出现在源代码中。我通常使用机械化,但是我认为它不会起作用。我该怎么办?我可以使用python或perl。 问题答案: 礼貌的选择是询问网站所有者是否具有允许您访问其新闻报道的API。 不太礼貌的选择是跟踪页面加载时发生的HTTP事务,并确定哪一个是AJAX调用,该调用会提取数据。 看起来就是这个。但是看起来它可能包含会

  • 主要内容:1. 配置Apache以允许CGI,2. 编写CGI程序CGI(公共网关接口)定义了Web服务器与外部内容生成程序交互的方式,这些程序通常被称为CGI程序或CGI脚本。这是一种使用您最熟悉的编程语言将动态内容放在网站上的简单方法。本文档将介绍如何在Apache Web服务器上设置CGI,以及如何编写简单的CGI程序。 1. 配置Apache以允许CGI 为了使CGI程序正常工作,需要配置Apache以允许CGI执行。有几种方法可以做到这一点。 方式1: