dojo Menu plugin not working...

Vote:
 

I'm creating a custom toolbar button usng Dojo as described here:  http://tedgustaf.com/blog/2014/6/add-a-custom-toolbar-button-in-episerver-7/ I'm fairly sure I've got everything wired up correctly, but when I start the site and enter edit mode, I get the following error:

Unhandled exception at line 2, column 1738 in http://jrcms7mvc/epi/Shell/7.9.1.0/ClientResources/epi/epi.js

0x800a139e - JavaScript runtime error: Could not resolve dependency "epi.globalcommandregistry" (epi.dependency)

The code for my button registration module, WorkflowCommands.js in the folder ClientResources/Scripts/widgets/widgetlib is as follows:

define([
    'dojo/aspect',
    "dojo/_base/declare",
    "epi/dependency",
    "ultimedia/widgetlib/WorkflowUpdateCommand"
], function 
   (
        aspect,
        declare,
        dependency,
        WorkflowUpdateCommand
    ) {

    var handle,
        registry = dependency.resolve('epi.globalcommandregistry'),
        callback = function (identifier, provider) {
            if (identifier !== "epi.cms.globalToolbar") {
                return;
            }
            provider.addCommand(new WorkflowUpdateCommand(), { showLabel: true, id: "WorkflowUpdateCommand", disabled: true }); // Disabled until we navigate to relevant content
            handle.remove();
        };

    handle = aspect.after(registry, 'registerProvider', callback, true);
});

My module.config file (in the website root) looks like this:



    
	    
        
    
    
        
        
    
    
        
        
            
        
    
    
        
    

I think I need to register a dependency on the Shell module, but I'm not sure how - anyone got any ideas?

Thanks in advance,

Mark

#89117
Aug 07, 2014 14:58
Vote:
 

Hello Mark,

Did you find the issue? I have the same problem.

Thanks,

Regards.

#112550
Oct 29, 2014 22:51
Vote:
 

I would guess that your module is loading before the EPiServer module has loaded (as mentioned in the comments to Ted's post). Add the following to your module.config

<clientModule>
    <moduleDependencies>
        <add dependency="Shell" />
        <add dependency="CMS" />
    </moduleDependencies>
</clientModule>
#112780
Nov 05, 2014 13:04
Vote:
 

Ben,

I added the <clientModule> section to the module.config file in the site root, but still get the same issue.

Should I be adding the section to a module.config file in the same folder as my WorkflowCommands.js file?

I raised issue DI-142857 on October 6th for this, and uploaded a test case, but haven't heard anything since, despite repeated reminders.

#112787
Nov 05, 2014 14:00
Vote:
 

It seems odd to me that you would have two module.config files but in any case it should be in the one that is loading the JavaScript stuff. The idea being that you want to delay loading and running your JavaScript till the EPiServer module has loaded.

Also you would probably get away with only having a dependency on Shell. So you can probably remove the line with the CMS dependency in the code I posted previously.

And finally I'm not part of the support team so I can't help you with the support case. I just happened to be browsing the forums ;) I have pinged them however and hopefully they pick this up.

#112788
Nov 05, 2014 14:11
Vote:
 

Thanks for that Ben,

I'm sure I've misconfigured something, but haven't been able to work out what.

Hopefully Developer Support will get back to me with what I've done wrong.

#112789
Nov 05, 2014 14:18
Vote:
 

Developer Support put me right on this: the 'define([' on line 1 of the WorkflowCommands.js should be 'require(['

#114060
Dec 03, 2014 15:37
Vote:
 

You are correct.

#114063
Dec 03, 2014 15:44
Vote:
 

I've upgraded to 7.19 and getting the same error, have changed define to require and added shell to module.config, still same error is throwed. Any more ideas?

#117268
Feb 16, 2015 11:44
Vote:
 

After the upgrade to 7.19.2 and EPiServer.CMS.UI to 7.18.0 this stopped working. I am getting the error

"Error: Could not resolve dependency "epi.globalcommandregistry" (epi.dependency)" Any ideas?

#121552
May 13, 2015 16:38
Vote:
 

The "epi.globalcommandregistry" dependency is setup in the initialization of our Shell module. If you can not resolve the dependency then your code must be running before the Shell module is initialized. If you run in debug mode then I believe we log the module initialiation to the console. This would be the best place to start debugging.

Also if you are using the above hack then I recommend you rewrite you code to use a module initializer and the initializer attribute in the module config that was added in 7.5 http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/75/Configuration/Configuring-moduleconfig/#clientModule

#121870
May 19, 2015 10:53
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.