Download Backbone.Relational using Use! plugin

Backbone Relational is not an AMD-compatible library, so I went ahead and found a usage plugin to ensure that the underline and trunk load as dependencies. Here is my configuration file

require.config({ baseUrl: '../global/js', paths: { use: 'libs/utilities/use', jquery: 'libs/jquery/jquery-min', underscore: 'libs/underscore/underscore-min', backbone: 'libs/backbone/backbone-optamd3-min', text: 'libs/require/text', relational: 'libs/backbone/backbone-relational' }, use: { "relational": { deps: ["backbone","underscore"] } } }); 

I also went ahead and added the Backbone relational library

 (function(Backbone, _) { "use strict"; Backbone.Relational = { showWarnings: true }; })(this.Backbone, this._); 

Finally, I call relational inside the model

  define([ 'jquery', 'underscore', 'backbone', 'mediator', 'relational' ], function($, _, Backbone, Mediator){ 

I get an error, cannot set Relational property from undefined. Master's value is not available. What am I missing?

Some links that I used https://github.com/tbranyen/use.js
https://github.com/tbranyen/layoutmanager-example/blob/master/app/index.js
https://raw.github.com/PaulUithol/Backbone-relational/master/backbone-relational.js

0
source share
2 answers

Trunk and underline are not compatible with AMD.

Update Warning: Version 1.3.0 and later removes AMD support (RequireJS).

0
source

To use the (sic) use plugin that you don’t need, the underscore / trunk versions of AMD are needed. You need to wrap them, respectively, i.e. In your require configuration file:

  use: { backbone: { deps: ["use!underscore", "jquery"], attach: "Backbone" }, underscore: { attach: "_" }, relational: { deps: ["use!underscore", "use!backbone"] } .... } 
0
source

All Articles