0

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

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);
}

因此,每次我调用它时,它都会附加到网格而不是覆盖它,这就是我想要的。如何实现?

4

1 回答 1

0

使用.html()而不是.append()/.prepend()as.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);
}
于 2013-11-26T12:09:32.233 回答