I'm working on a fairly large web app in which I am going to be using require.js so I can compile it once it's ready for production, but I would like to use backbone-relational. I am also going to be using backbone-marionette, but I am not sure how it would be included in the define function of modules.
Does anyone have any experience with this?
I'm using Backbone Marionette with Relational and loading them with Require.js. The basic idea is that you need to ensure Relational is loaded. One way to do it is to include Relational as a requirement whenever you define a Relational model.
In my project, I created a simple script called bbloader.js (Backbone Loader) that loads all the relevant backbone models:
define([
'backbone',
'iosync',
'iobind',
'relational',
'marionette',
'marionette.async'
], function(Backbone) {
return Backbone;
});
And then throughout the project, I require bbloader instead of Backbone. For example:
define([
'jquery',
'underscore',
'bbloader',
// ...
], function($, _, Backbone) {
// ...
});
Backbone Relational is already AMD compatible, so you shouldn't need to do anything extra there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With