I found the problem. I had been going through my code and "optimizing" (so I thought) some of the redundancies.
Instead of this:
define(["backbone"], function( Backbone ){
var model = Backbone.Model.extend({
myfunc : function(){ /*do stuff */}
});
return model;
});
I had changed a bunch of code to look like this:
define(["backbone"], function( Backbone ){
return Backbone.Model.extend({
myfunc : function(){ /*do stuff*/ }
});
});
Not a problem right? Mostly.
I was ALSO using a nifty trick I read about on another post about getting singleton functionality from require.js modules by returning an instantiated model! Cool... mostly.
I had this:
define(["backbone"], function( Backbone ){
var singleton = Backbone.Model.extend({
myfunc : function(){ /*do singleton stuff*/ }
});
// because require.js only runs this code once, this essentially creates a singleton!
return new singleton();
});
and it worked great!
Then I got cocky...
define(["backbone"], function( Backbone ){
return new Backbone.Model.extend({
myfunc : function(){ /*do singleton stuff... no more!*/ }
})();
});
and I started getting my has no method 'apply' error.
It took me the better part of 2 days and lots of frustration to track down the problem and I finally got the answer from this post:
new Backbone.Model() vs Backbone.Model.extend()
It explains nicely how you can instantiate Backbone.Model but Backbone.Model.extend merely provides you with a constructor that you can THEN use to instantiate a custom Backbone.Model object.
I hope this saves someone the pain I just went through.