London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
Hi!
I suggest that you create an init module on the client since this will make the code run at the right time. Here is a copy paste example from something I worked on recently:
Module.config:
<clientModule initializer="[your module class including namespace]">
<moduleDependencies>
<add dependency="CMS" type="Require RunAfter" />
</moduleDependencies>
</clientModule>
Client module sample:
define([ // Pull in the patches. Not used here, just evaluated, since this is the first module loaded when starting the application. "dojo/_base/declare", "dojo/_base/lang", "epi/_Module", "epi/dependency", "instantTemplates/AddItemFromTemplateCommandProvider" ], function ( declare, lang, _Module, dependency, AddItemFromTemplateCommandProvider ) { return declare([_Module], { // summary: // Template module implementation. // // tags: // internal _settings: null, constructor: function (settings) { this._settings = settings; }, initialize: function () { var commandregistry = dependency.resolve("epi.globalcommandregistry"); //We need to wait for the viewsettings to initialized before creating the global toolbar command provider commandregistry.registerProvider("epi.cms.globalToolbar", new AddItemFromTemplateCommandProvider({templatesRoot : this._settings.templatesRoot})); } }); });
Linus,
That did it for me (specifically the module.config settings) - thanks!.
I have the following javascript in the file ClientResources/Scripts/widgets/media/Mediacommands.js:
My module.config looks like this:
This is intended to add a button to the Editor toolbar, and *sometimes* works. However around 70% of the time I see the error Can't resolve dependency "epi.globalcommandregistry" in the console.
This corresponds to the line registry = dependency.resolve('epi.globalcommandregistry'), in the javascript above.
Is there any reason why the dependency can't be resolved at some times and more to the point, how can I ensure it's resolved every time?
Thanks,
Mark