我在将dojo模块添加到用户界面时遇到了一些麻烦。它尝试在episerver / shell中进行访问。 我添加了一个module.conifg;
<module>
<assemblies>
<add assembly="Mobile.Web" />
</assemblies>
<dojoModules>
<add name="MobileWeb" path="Scripts" />
</dojoModules>
</module>
在~/ClientResources/js/KeyValueEditor.js
添加了我的dojo模块,
命名模块declare('MobileWeb.js.KeyValueEditor', [widget, templatedMixin]
并在我的块类型中:
[ClientEditor(ClientEditingClass = "MobileWeb.js.KeyValueEditor")]
public virtual string KeyValueCategoryData { get; set; }
它有时会起作用,但是当我改变了dojoModules - &gt;将名称属性添加到MobileWeb,它将不再工作。 谁知道这可能是什么?
答案 0 :(得分:1)
看起来系统不知道在哪里可以找到客户端资源。
dojoModules节点中的名称是您的名称空间的一种,路径应指向Dojo可以找到该名称空间的资源/脚本的文件夹。此路径与模块根目录相关。
据我所知,您可能希望将JavaScript文件放在ClientResources / js子文件夹中,将样式放在模块目录中的ClientResources / css子文件夹中。在这种情况下,您可以像这样定义Dojo模块:
<dojoModules>
<add name="MobileWeb" path="ClientResources/js" />
</dojoModules>
这意味着系统将尝试在模块目录中的ClientResources / js子文件夹中查找资源。声明小部件时,您应该遵循命名空间和文件夹结构。您可以在ClientResources / js / KeyValueEditor.js文件中声明您的小部件,如下所示:
define([
// your imports
],
function (/* imports */) {
return declare("MobileWeb.KeyValueEditor", [_Widget, /* … */ ], {
// implementation
});
});
然后,当您在后端C#代码中引用窗口小部件时,可以使用MobileWeb.KeyValueEditor名称。
您可以在sample add-on for EPiServer 7中找到一些示例和源代码。