0
我试图做到这一点使用下面的模板型号:如何在Dojo Widget的另一个模板中包含模板?
<div>
<div data-dojo-attach-point="includeHere"</div>
</div>
和
<div>
${includeHere}
</div>
在我认为应该是这样的类
然后:
define([
"dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dojo/text!./templates/myWidget.html",
"dojo/text!./templates/templateToBeIncluded.html"
], function (
declare,
_WidgetBase,
_TemplatedMixin,
template,
templateToBeIncluded
) {
return declare([_WidgetBase, _TemplatedMixin], {
templateString: template,
buildRendering: function() {
this.includeHere = templateToBeIncluded;
},
});
});
我cheked _TemplatedMixin源代码,并尝试按照_TemplatedMixin的方式更改构建渲染函数:
buildRendering: function() {
domConstruct.toDom(templateToBeIncluded, this.includeHere);
},
但LSO不能使它发挥作用。什么是正确的方法来做到这一点?我不想在我的.js文件中包含HTML。我只想在模板中使用HTML。
为什么你需要这个?你是否需要在另一个小部件中包含一个小部件?可以帮忙吗? http://stackoverflow.com/questions/9306670/adding-dojo-widget-inside-custom-widget – Radex
那么......我仍然在Dojo开始。也许我没有得到“Dojo方式”做事。但实际上这个想法是我不需要widget中的小部件...我只需要一个子模板。但是,第二个想法,几乎是一回事,不是吗?好吧...你认为我应该将子模板转换为小部件吗? –