RequireJS: load a module from a different context

I have two configurations (two contexts):

var requirePortal = require.config({
    context: 'portal',
    baseUrl: '',
    paths: {
        'jquery': 'assets/js-vendors/jquery/dist/jquery',
        'underscore': 'assets/js-vendors/underscore/underscore',
        'backbone': 'assets/js-vendors/backbone/backbone',
        // ...
    }
});

var requireSample = require.config({
    context: 'sample',
    baseUrl: '<adress>/other-context',
    paths: {
        'viewFactory': 'application/util/ViewFactory',
        'indicador':   'application/models/indicador'
    }
});

Here, the portal context will have all the components of the providers, and in the example context the modules will be used for use. Then I have to load the provider components from the context of the example:

define([
    'indicador'
], function(IndicadorModel) {
    var IndicadorPagerCollection = PagerCollection.extend({
        model: IndicadorModel,
        baseUrl: 'rest/manter/indicadores'
    });
    return IndicadorPagerCollection;
});

In this case, it PagerCollectionis a component of the provider and is in the context of the portal. How can i do this?

+4
source share

All Articles