in js/views/todo-view.js [82:110]
close: function () {
var value = this.$input.val();
var trimmedValue = value.trim();
// We don't want to handle blur events from an item that is no
// longer being edited. Relying on the CSS class here has the
// benefit of us not having to maintain state in the DOM and the
// JavaScript logic.
if (!this.$el.hasClass('editing')) {
return;
}
if (trimmedValue) {
this.model.save({ title: trimmedValue },{patch:true});
if (value !== trimmedValue) {
// Model values changes consisting of whitespaces only are
// not causing change to be triggered Therefore we've to
// compare untrimmed version with a trimmed one to check
// whether anything changed
// And if yes, we've to trigger change event ourselves
this.model.trigger('change');
}
} else {
this.clear();
}
this.$el.removeClass('editing');
},