0

I have some trouble adding my dojo module to the user interface.It tries to access in the episerver/shell. I have added a module.conifg;

<module>

  <assemblies>
    <add assembly="Mobile.Web" />
  </assemblies>

  <dojoModules>
    <add name="MobileWeb" path="Scripts" />
  </dojoModules>

</module>

Added my dojo module at ~/ClientResources/js/KeyValueEditor.js, named the module declare('MobileWeb.js.KeyValueEditor', [widget, templatedMixin] and in my block type:

[ClientEditor(ClientEditingClass = "MobileWeb.js.KeyValueEditor")]
public virtual string KeyValueCategoryData { get; set; }

It works sometimes, but when I changed the dojoModules -> add name attribute to MobileWeb, it wont work anymore. Anyone knows what this can be?

ptf
  • 3,210
  • 8
  • 34
  • 67

1 Answers1

1

It looks like the system don’t know where to find client resources.

The name in the dojoModules node is kind of your namespace and the path should point to the folder where Dojo can find resources/scripts for that namespace. This path is relative to your module root directory.

As I understand you probably want to put your JavaScript files in ClientResources/js subfolder and your styles in ClientResources/css subfolder inside your module directory. In this case you can define Dojo module like this:

<dojoModules>
  <add name="MobileWeb" path="ClientResources/js" />
</dojoModules>

It means that system will try to find resources in ClientResources/js subfolder in your module directory. When declaring widgets you should follow your namespace and folder structure. You can declare your widget in ClientResources/js/KeyValueEditor.js file like this:

define([
// your imports
],
function (/* imports */) {
    return declare("MobileWeb.KeyValueEditor", [_Widget, /* … */ ], {
        // implementation
    });
});

And then you can use MobileWeb.KeyValueEditor name when you reference your widget in the back-end C# code.

You can find some examples and source code in sample add-on for EPiServer 7.

Dmytro Duk
  • 184
  • 2