user1775888
user1775888

Reputation: 3313

require a library module in requirejs

I want to execute Nav.init(), Nav1.init() both after dom ready so I call DomReady module inside Nav, Nav1 each module before.

Now I try edit the code to call DomReady module before require them both, then just need to write one time but because there is a require parameter I don't know how should I do?
Does it like this define(['require','DomReady!'], function (require, DomReady) { ?

define(['DomReady!'], function (require, DomReady) {
  var Nav = require('custom/Nav');
  Nav.init();

  var Nav1 = require('custom/Nav1');
  Nav1.init();
});

Upvotes: 0

Views: 27

Answers (1)

Linh Pham
Linh Pham

Reputation: 3025

Try this

define(['DomReady!'], function (DomReady) {
  require(['custom/Nav'], function(Nav){
    Nav.init();   
  });
  

  require(['custom/Nav1'], function(Nav1){
    Nav1.init();   
  });
});

Upvotes: 1

Related Questions