【问题标题】:How to remove backgridjs row to display new rows?如何删除 backgridjs 行以显示新行?
【发布时间】:2013-11-20 11:59:43
【问题描述】:

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

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

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

【问题讨论】:

    标签: javascript backbone.js backgrid


    【解决方案1】:

    使用.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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多