如何删除backgridjs行以显示新行?

时间:2013-11-20 11:59:44

标签: javascript backbone.js backgrid

这会将一组新行附加到原始网格:

var refreshgrid = function(){
    var grid = new Backgrid.Grid({
      columns: columns,
      collection: ter
    });

    // Render the grid and attach the root to your HTML document
   // $("#example-1-result").append(grid.remove());
    $("#example-1-result").prepend(grid.render().$el);
}
因此,每当我调用它时,它会附加到网格而不是覆盖它,这就是我想要的。 如何实现呢?

1 个答案:

答案 0 :(得分:0)

使用.html()代替.append()/.prepend().html()删除/覆盖旧值:

var refreshgrid = function(){
    var grid = new Backgrid.Grid({
      columns: columns,
      collection: ter
    });

    // Render the grid and attach the root to your HTML document
    $("#example-1-result").html(grid.render().$el);
}