2013-03-25 46 views
0

我試圖渲染骨幹網ui表時收到「Uncaught TypeError:Can not call method'table of'undefined」。我只是試圖從網站呈現示例表。我試圖搜索變量的設置,但似乎沒有任何工作。任何幫助不勝感激。示例代碼如下。一個簡單的集合,我試圖在骨幹ui表視圖中顯示。 JS錯誤發生在骨幹內部的渲染方法中-ui.js

window.regions = new Backbone.Collection([{ 
    name: 'Americas', 
    notes: 'Bright' 
}, { 
    name: 'Africa', 
    notes: 'Fruity' 
}]); 

var table = new Backbone.UI.TableView({ 
    el: $('#table_container'), 
    sortable: true, 
    model: regions, 
    columns: [{ 
     title: 'Name', 
     content: 'name' 
    }, { 
     title: 'Notes', 
     content: 'notes' 
    }] 
}).render(); 
+0

我擁有了一切包在$(文件)。就緒(函數(){}) – kralcen 2013-03-25 23:52:04

回答

0

我不能讓它去,所以我改變了使用數據表JS

0

查看Backbone UI源,TableView不接受el作爲選項。這可能就是爲什麼你在渲染時遇到錯誤。嘗試刪除它。您應該嘗試將其包裝到容器中或將其附加到DOM(取決於#table_container是否已存在或不在)後渲染。

table.appendTo('#table_container); 

table.wrap('<div id="table_container"></div>').appendTo(~wherever~);