Can we create dojo declarative(not programatic) titlePane inside template based widget?

StackOverflow https://stackoverflow.com/questions/23561617

  •  18-07-2023
  •  | 
  •  

Can we create dojo declarative titlePane inside template based widget?

When I am creating a titlePane out side the template file like :

It is working, but as soon as I have moved this code to html template file it is not working. (I am attachiong this file to dojo widget)

有帮助吗?

解决方案

You should be able to add widgets in your template yes. There are only a few things you have to remind:

  • You can not use a widget as the root element of the template,
  • You should inherit from the dijit/_WidgetsInTemplateMixin as well,
  • Like all declarative markup, you still have to include the module itself (dijit/TitlePane), by adding it either to your require() or define(). For example:
declare("my/Widget", [ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], {
    title: "My title",
    content: "My content",
    templateString: "<div>" +
    "<div data-dojo-type=\"dijit/TitlePane\" data-dojo-props=\"title: '${title}'\">${content}</div>" +
    "</div>"
});

I also made an example JSFiddle.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top