2015-05-08 107 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'); 
      }); 

我仍然開放給了我最初問。

謝謝

相關問題