Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

backbone.js this._configure undefined when calling views

TypeError: Result of expression 'this._configure' [undefined] is not a function.

I keep running into this error any time I extend Backbone.View

my app structure looks like :

//index.js

$(function(){ 
  window.Project = Backbone.Model.extend({});
  window.ProjectCollection = Backbone.Collection.extend({});
  window.projects = new ProjectCollection;
  window.ProjectView = Backbone.View.extend({});
  window.view = ProjectView({});
  window.view.render();
});

Even with this blank structure I still get the error, and when I have all my code filled in I get the exact same error

Am I missing a dependancy? in my index.html I load the following in order:

jquery.js
underscore.js
backbone.js
(and at the bottom of my body) index.js

And if I take the 'window' off of my variables i get the same error.

No matter how I approach backbone.js I keep getting this same error... how do I fix this?

like image 556
shanejonas Avatar asked Mar 05 '11 15:03

shanejonas


2 Answers

Try

window.view = new ProjectView;

instead of

window.view = ProjectView({});
like image 91
polarblau Avatar answered Nov 16 '22 15:11

polarblau


I was recently seeing this error too TypeError: this._configure is not a function and it was because I had:

var myView = someView();

instead of:

var myView = new someView();

like image 2
thehme Avatar answered Nov 16 '22 14:11

thehme