开发者

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 = Ba开发者_JAVA百科ckbone.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?


Try

window.view = new ProjectView;

instead of

window.view = ProjectView({});


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();


I needed to pass arguments to my view, so none of the options here worked for me.

I had this code:

return new app.module('foo').View({id: 1});

Changing it to this worked:

var view = app.module('foo').View;
return new view({id: 1});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜