Search code examples
liferay-6alloy-ui

How can I add a custom module to be loaded globally in AlloyUI?


I have written a custom module that works fine as part of main.js and would like to move it to a separate file. I am using liferay 6.1 GA3.

I have tried to add the following in main.js with no success:

YUI.GlobalConfig = ({
    modules: {
        'bb-select-detail': {
            fullpath: '/js/selectDetail.js',
            requires:["aui-base", "aui-loading-mask", "aui-io-request", "json-parse", "oop", "aui-parse-content"]
        }
    }
});

Many thanks, Alain


Solution

  • Have you tried with applyConfig instead?

    YUI.applyConfig({
        modules: {
            'bb-select-detail': {
                fullpath: '/js/selectDetail.js',
                requires:["aui-base", "aui-loading-mask", "aui-io-request", "json-parse", "oop", "aui-parse-content"]
            }
        }
    });
    

    You can use it both statically to apply to all YUI instances, or on a given instance.