0

只是一个小问题,但它让我发疯。我想使用 TabContainers 编写自己的小部件。现在看来,mixin-Classes 无法调用 TabContainer 模块并启动它们。我用不同的小部件尝试了很多东西,似乎 TabContainer 只是一个问题。查看文档我无法弄清楚它是 Dojo 中的错误还是我的代码中的错误。尽管如此,这行得通

<script type="text/template" id="editMultilanguageDialog-form-template">
  <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="form">
    <button data-dojo-type="dijit/form/Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconCut', showLabel: false" type="button">cut</button>
  </form>
</script>

……但这不是!

<script type="text/template" id="editMultilanguageDialog-form-template">
  <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="form">
    <div data-dojo-type="dijit/layout/TabContainer" style="width: 100%; height: 100%;">
        <div data-dojo-type="dijit/layout/ContentPane" title="My first tab" data-dojo-props="selected:true">
            Lorem ipsum and all around...
        </div>
        <div data-dojo-type="dijit/layout/ContentPane" title="My second tab">
            Lorem ipsum and all around - second...
        </div>
        <div data-dojo-type="dijit/layout/ContentPane" title="My last tab" data-dojo-props="closable:true">
            Lorem ipsum and all around - last...
        </div>
    </div>
  </form>
</script>

在 dialog.js 中调用的代码如下所示:

 define([ "modules/waitingDialog/dialog", "util/debugger", "stores/userStore",
    "util/storeCache", "dojo/Evented", "dijit/Dialog", "dojo/_base/lang",
    "dojo/_base/declare", "dijit/_Widget", "dijit/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin", "dojo/dom", "dojo/_base/Deferred",
    "modules/editMultilanguageDialog/controller", "stores/facultyStore",
    "stores/degreeStore", "stores/beginOfStudyStore" ], function(wait,
    debug, userStore, storeCache, Evented, Dialog, lang, declare, widget,
    templatedMixin, widgetsInTemplateMixin, dom, Deferred,
    editMultilanguageController, facultyStore, degreeStore,
    beginOfStudyStore) {
return declare("editMultilanguageDialog", [ Dialog, Evented ], {

    attributeMap : lang.delegate(widget.prototype.attributeMap, {
        message : {
            node : "messageNode",
            type : "innerHTML"
        }
    }),

    constructor : function(/* Object */kwArgs) {
        debug.log("constructor called",
                "editMultilanguageDialog.constructor()", 1);
        lang.mixin(this, kwArgs);

        var controller = new editMultilanguageController(kwArgs);
        this.controller = controller;

        var dialogTemplate = dom.byId("dialog-template").textContent;
        var formTemplate = dom
                .byId("editMultilanguageDialog-form-template").textContent;
        var template = lang.replace(dialogTemplate, {
            form : formTemplate
        });

        var contentWidget = new (declare([ widget, templatedMixin,
                widgetsInTemplateMixin ], {
            templateString : template,
            widgetsInTemplate : true
        }));

        var content = this.content = contentWidget;

        this.form = content.form;

        contentWidget.startup();
    }, [...]

这个问题快把我逼疯了。认为任何人都可能通过编写自定义小部件遇到同样的问题。提前谢谢!

4

0 回答 0