L
L
lgick2014-02-20 02:13:18
RequireJS
lgick, 2014-02-20 02:13:18

RequireJS module loading

Addresses of additional components for the factory come from the server and they need to be run in the current context.
Without requireJS, this can be done using global variables and a generated script.
How to do it with requireJS?
You can do this inside a module:

require(['Factory', 'require'], function (Factory, require) {
 
// ... тут какой-то код
 
  // добавляет зависимости
  function addDependence(name, path) {
    require([path], function (module) {
      Factory.add(name, module);
      console.log(Factory.ModuleX);  // вернет модуль    
    });
 
    console.log(Factory.ModuleX);  // вернет undefined
  }
 
console.log(Factory.ModuleX);  // вернет undefined
});

but the data will not go beyond the function
how to load the module?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lgick, 2014-02-20
@lgick

this is an asynchronous file upload

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question