如何在Dojo Toolkit中为带按钮的工具栏定义Widget类?

ttp71kqs  于 2022-12-16  发布在  Dojo
关注(0)|答案(1)|浏览(219)

我将创建一个新的类-工具栏与标准操作按钮**(添加,编辑,删除,刷新)**。我写了简单的类:

define([
    "dojo/_base/declare",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin",
    "dijit/Toolbar",
    // Template for new widget
    "dojo/text!/ui/widgets/StandardToolbar.html",
    // Load dijit/form/Button widget as dependency for parsing template
    "dijit/form/Button"
], function(declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, Toolbar, templateString){
    return declare("app.StandardToolbar", [
        _WidgetBase,
        _TemplatedMixin,
        _WidgetsInTemplateMixin,
        Toolbar
    ], {
        templateString: templateString
    });
});

从基本工具栏扩展的模板:

<div class="dijit" role="toolbar" tabIndex="${tabIndex}" data-dojo-attach-point="containerNode">
  <button data-dojo-type="dijit/form/Button" data-dojo-attach-point="addButton">Add</button>
  <button data-dojo-type="dijit/form/Button" data-dojo-attach-point="editButton">Edit</button>
  <button data-dojo-type="dijit/form/Button" data-dojo-attach-point="removeButton">Remove</button>
  <button data-dojo-type="dijit/form/Button" data-dojo-attach-point="refreshButton">Refresh</button>
</div>

而且它不起作用。工具栏中的按钮呈现为标准的HTML按钮,而不是Dojo小部件。我做错了什么?

epfja78i

epfja78i1#

我认为您只是错过了在模板containerNode div中设置dojo类型data-dojo-type='dijit/Toolbar'
您必须设置:

<div data-dojo-type='dijit/Toolbar' class="dijit" role="toolbar" tabIndex="${tabIndex}" data-dojo-attach-point="containerNode">

x一个一个一个一个x一个一个二个x

相关问题