Reputation: 39
I am trying to set up a new application using Backbone.Marionette and RequireJS. I am following along with enzo's guide to set up my routers and controllers but am getting the following error- "Undefined is not a function" when trying to instantiate the controller.
require( ['marionette', './assets/js/router', './assets/js/routeController'], function (Marionette, Router, routeController) {
var MyApp = new Backbone.Marionette.Application();
var controller = new routeController({});
And if I hover over routeController in the function paramater is shows as "undefined."
What am I doing wrong? This is driving me insane.
Edit: The routeController file is as follows-
define(["marionette"], function (Marionette) {
var Controller = Backbone.Marionette.Controller.extend({
initialize : function(options) {
},
start: function() {
},
home : function () {
alert('Hello, welcome home!');
},
});
return Controller;
});
Upvotes: 0
Views: 128
Reputation: 2092
When you get a null
when requesting a module from RequireJS, there are two typical possibilities:
1) The module being required in isn't returning something
Is Controller
non-null in routeController.js
? Throw a debugger in there to make sure.
2) There is a circular dependency somewhere
It's easy enough to create a circular dependency somewhere in your modules. Doesn't look like that's the case here, but could happen if router.js
is doing something funky.
Upvotes: 1