cod*_*ode 1 javascript backbone.js
同一个对象有很多问题.但我的情况略有不同.不同的是,在我的问题中我不使用任何Backbone模型只有骨干视图.
我只使用Backbone View.以下是初始化视图时的错误堆栈.
Uncaught TypeError: Cannot use 'in' operator to search for 'model' in ace-edit-spec-examples-1-8
(anonymous function) underscore.js:783
_.each._.forEach underscore.js:78
_.pick underscore.js:782
_.extend._configure backbone.js:1086
Backbone.View backbone.js:983
child backbone.js:1529
Backbone.View.extend.render itemview.js:90
Backbone.View.extend.addListItem listview.js:99
Backbone.View.extend.renderList listview.js:84
(anonymous function) listview.js:42
_.each._.forEach underscore.js:78
Backbone.View.extend.render listview.js:41
Backbone.View.extend.render tabview.js:124
(anonymous function) tabview.js:50
collection.fetch.success util.js:28
options.success backbone.js:854
fire jquery.js:1037
self.fireWith jquery.js:1148
done jquery.js:8074
callback
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
编辑:
我的看法
var AceEditorView = Backbone.View.extend({
initialize: function (id,type,here) {
this.id = id;
this.type = type;
this.here = here;
//this.render();
}});
Run Code Online (Sandbox Code Playgroud)
我的电话:
new AceEditorView('ace-edit-spec-examples-1-'+json.id,'json',this);
Run Code Online (Sandbox Code Playgroud)
对于签名Backbone.View.constructor/Backbone.View.initialize是new View([options]),所以你必须通过你的参数选项的哈希值.尝试
var AceEditorView = Backbone.View.extend({
initialize: function (opts) {
this.id = opts.id;
this.type = opts.type;
this.here = opts.here;
}
});
Run Code Online (Sandbox Code Playgroud)
并将其实例化为
new AceEditorView({
id: 'ace-edit-spec-examples-1-'+json.id,
type: 'json',
here: this
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3336 次 |
| 最近记录: |