cloudflarearchive / backgrid

Finally, an easily stylable semantic HTML data grid widget with a Javascript API that doesn't suck.
http://backgridjs.com
MIT License
2.01k stars 325 forks source link

Why is backgrid:edited not triggered by BooleanCellEditor's saveOrCancel when e.type=="change" #560

Closed dexygen closed 8 years ago

dexygen commented 9 years ago

Is this by design or an oversight? Certainly a change constitutes an edit? These are the last lines of BooleanCellEditor's saveOrCancel method however and unlike other parts of the the same method,

model.trigger("backgrid:edited", model, column, command) 

does not get called:

else if (e.type == "change") {
  var val = formatter.toRaw($el.prop("checked"), model);
  model.set(column.get("name"), val);
  $el.focus();
}
wyuenho commented 8 years ago

This is by design. The change event handler is only there to deal with event order inconsistencies among browsers. It's used to save the changes when space is pressed. I'm not sure what problem this actually causes, but if you are looking to programmatically saving a value to the model, you have better luck programmatically generating a keydown event instead of a change event.