2013-08-27 39 views
1

來自同一個對象的問題很多。但我的情況有點不同。區別在於,在我的問題中,我沒有使用任何骨幹模型僅骨幹視圖。無法使用'in'運算符來搜索'model'

我只使用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 

任何幫助?

編輯:

我看來

var AceEditorView = Backbone.View.extend({ 
     initialize: function (id,type,here) { 
      this.id = id; 
      this.type = type; 
      this.here = here; 
      //this.render(); 
     }}); 

我的電話:

new AceEditorView('ace-edit-spec-examples-1-'+json.id,'json',this); 
+0

請分享代碼視圖,並創建它的功能。 –

+0

請現在審查' – codeofnode

回答

6

的簽名Backbone.View.constructor/Backbone.View.initializenew View([options]),所以你必須通過你的參數選項的哈希值。嘗試

var AceEditorView = Backbone.View.extend({ 
    initialize: function (opts) { 
     this.id = opts.id; 
     this.type = opts.type; 
     this.here = opts.here; 
    } 
}); 

並創建實例作爲

new AceEditorView({ 
    id: 'ace-edit-spec-examples-1-'+json.id, 
    type: 'json', 
    here: this 
}); 
+0

我發現傳遞參數不作爲散列工作在開發中,但一旦你壓縮與需求,然後我得到的錯誤OP提到。 – Lewis42

相關問題