Reputation: 509
I'm new to Backbone.js and i'm using it for a data visualization, as a school project. I've implemented require.js after some weeks of work, following this tutorial: http://backbonetutorials.com/organizing-backbone-using-modules/
I've reorganized my code then, but now i got an error that i'm not able to fix... I use Datamaps (http://datamaps.github.io/) to create a world map. I passed the needed scripts in the require define() function, but i'm probably doing something wrong.
Here is the code part which provide the error :
define([
'jquery',
'underscore',
'backbone',
'd3',
'c3',
'topojson',
'datamaps',
'jqueryui',
'text!templates/map.html'
], function($, _, Backbone, mapTemplate){
var MapView = Backbone.View.extend({
el: $('.container'),
initialize: function(){
var _this = this;
var map = new Datamap({ ... })
...
And the browser respond with "Uncaught ReferenceError: Datamap is not defined". It was working before, and since i use require, it doesn't work anymore, i've probably missed a param or something else.
I would appreciate some help on this ;)
Thank you in advance!
Upvotes: 1
Views: 1001
Reputation: 8090
With RequireJS when you define a module with dependencies, the dependencies are passed as arguments to your module definition function. Hence you need to match them. For e.g.,
define([
'jquery',
'underscore',
'backbone',
'd3',
'c3',
'topojson',
'datamaps',
'jqueryui',
'text!templates/map.html'
],
function($, _, Backbone, D3, C3, Topojson, Datamaps, jQueryUI) {
// and in here you can then use the modules ...
});
Upvotes: 1