2015-05-08 52 views
0

我只想检查是否有另一种方法检查单元格是否已被编辑。目前这里是我的代码片段。这是一个自定义单元格编辑器。检查是否编辑了单元格

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

最后一部分,我选择当前datetimepicker的父td操纵,并添加一个新的类不工作。虽然我试图找到一个解决方案来实现这个功能,但我只想知道,如果已经有更好的方法来检查单元格是否已被编辑过,

在此先感谢

回答

0

我做了我的代码通过在自定义单元格的initializiation添加监听莫名其妙地工作。

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

我仍然开放给了我最初问。

谢谢