Reputation: 73
How can I include a view from another file (e.g. Views.js) in a JavaScript file loaded as a Require.js module? I receive a "Uncaught TypeError: object is not a function" error when I try to instantiate myView.
define([
'jQuery',
'Underscore',
'Backbone',
'src/Views'
], function ($, _, Backbone, myView) {
new myView ({ });
});
Upvotes: 0
Views: 316
Reputation: 638
Do your "src/views.js" have a return value?
some like this:
define(['underscore', 'backbone'], function(_, Backbone) {
var view = Backbone.View.extend({
......
});
return view; //the return value is essential
});
Upvotes: 1