【问题标题】:Check if backgrid cell was edited检查 backgrid 单元格是否被编辑
【发布时间】:2015-05-08 03:15:41
【问题描述】:

我只想检查是否有其他方法可以检查单元格是否已被编辑。目前这里是我的代码 sn-p。这是一个自定义单元格编辑器。

Backgrid.CustomDateCell = Backgrid.DateCell.extend({
    editor: Backgrid.InputCellEditor.extend({
        attributes: {
            type: "text"
          },
        events: {},
        initialize: function(){
            Backgrid.InputCellEditor.prototype.initialize.apply(this, arguments);
            var _input = this;
            $(this.el).prop('readonly', true);
            $(this.el).datepicker({
                autoclose: true,
                todayHighlight: true,
                format: "mm/dd/yyyy",
                viewMode: "months",
                minViewMode: "months"
            });
            $(this.el).on('hide', function(e){
                var command = new Backgrid.Command({});
                _input.model.set(_input.column.get("name"), e.date);
                _input.model.trigger("backgrid:edited", _input.model, _input.column, command);
                command = _input = null;

                $(this).parent('td').addClass('cell-edited');
            });
        }
    })
});

我选择当前日期时间选择器的父 td 操作并添加新类的最后一部分不起作用。虽然我正在尝试找到解决方案来使其正常工作,但我只想知道 backgrid 是否已经有更好的方法来检查单元格是否已被编辑。

提前致谢

【问题讨论】:

    标签: jquery backbone.js editor cell backgrid


    【解决方案1】:

    我通过在自定义单元格的初始化中添加一个侦听器使我的代码以某种方式工作。

    this.listenTo(_input.model, "backgrid:edited", function(){
                    $(this.el).parent().parent().addClass('cell-edited');
                });
    

    我仍然愿意接受我最初提出的要求。

    谢谢

    【讨论】:

      猜你喜欢
      • 2012-05-08
      • 2021-05-30
      • 1970-01-01
      • 1970-01-01
      • 2011-03-15
      • 2012-01-05
      • 1970-01-01
      • 2012-05-03
      • 1970-01-01
      相关资源
      最近更新 更多