2013-08-23 49 views
1

當我使用的layoutManager與manage設置爲true渲染Backgrid使用的layoutManager

Backbone.Layout.configure({ 
    manage: true 

這攪亂Backgrid的渲染。

manage設置爲false那麼表被正確渲染,但如果我設置managetrue,則該表不會呈現完全(沒有表頭或身體),但只有<table class="backgrid"></table>

回答

1

我知道這是一個老問題,但這是因爲LayoutManager和Backgrid都使用「渲染」功能。將manage設置爲true時,LayoutManager會用自己的替代函數覆蓋Backgrid的渲染函數。

我這樣做的方式是製作一個新的視圖來擴展Backgrid並直接調用它的渲染函數。

var myGrid = Backgrid.Grid.extend({ 
 
    manage:true, 
 
\t 
 
    initialize: function(options) { 
 
    Backgrid.Grid.prototype.initialize.call(this,options)); 
 
    this.renderGrid(); 
 
    }, 
 
\t 
 
    renderGrid: function() { 
 
    Backgrid.Grid.prototype.render.call(this); 
 
    return this; 
 
    } 
 
    
 
});