Richard
Richard

Reputation: 32959

Require.JS: loading modules that are dependent on each other?

I'm just getting started with Require.JS and I have a (hopefully) simple question.

I'm using jQuery and SlickGrid, and I have loaded all my modules at the top of my main.js file as follows:

require(["jquery", "underscore-1.3.1", "backbone-0.9.1", 
     "plugins/jquery.event.drag-2.0.min", "plugins/slick.core", 
     "plugins/slick.grid", "plugins/slick.dataview"], function($) { ...

This works OK in Chrome and Firefox, but in Safari I get a few error warnings:

SlickGrid requires jquery.event.drag module to be loaded
require-jquery.js:1632Error: Module name 'underscore' has not been loaded yet 
   for context: _http://requirejs.org/docs/errors.html#notloaded

SlickGrid is dependent on jquery.event.drag and Backbone is dependent on Underscore, and it looks like Safari dislikes them not being able to see each other.

Am I doing something wrong? Is there a way I can work around this?

Upvotes: 2

Views: 5997

Answers (2)

MarcD
MarcD

Reputation: 35

You should try the Requirejs Order Plugin to make sure the files are loaded in the right Order.

UPDATE: Please See Post below! The Order Plugin is outdated! USE SHIMS

PLZ See Konga Raju and Simon Smith Post!

Upvotes: -2

kongaraju
kongaraju

Reputation: 9606

requirejs order plugin is deprecated. See the requirejs documentation and use shim loading instead of order plugin.

Upvotes: 13

Related Questions