且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为backgrid行添加自定义删除选项

更新时间:2023-12-03 16:57:58

您可以制作自定义单元格。

You can make a custom cell.

var DeleteCell = Backgrid.Cell.extend({
    template: _.template(" PUT YOUR HTML BUTTON TEMPLATE HERE "),
    events: {
      "click": "deleteRow"
    },
    deleteRow: function (e) {
      e.preventDefault();
      this.model.collection.remove(this.model);
    },
    render: function () {
      this.$el.html(this.template());
      this.delegateEvents();
      return this;
    }
});