Skip to content

Commit

Permalink
backbone: trim on edit (ref tastejs#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
passy committed Aug 5, 2013
1 parent 8c48866 commit edde223
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions architecture-examples/backbone/js/views/todos.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ var app = app || {};

// Close the `"editing"` mode, saving changes to the todo.
close: function () {
var value = this.$input.val().trim();
var trimmedValue = this.$input.val().trim();
this.$input.val(trimmedValue);

if (value) {
this.model.save({ title: value });
if (trimmedValue) {
this.model.save({ title: trimmedValue });
} else {
this.clear();
}
Expand Down

1 comment on commit edde223

@kamilogorek
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't trigger change event on a model. Could you take a look at this solution? tastejs#707

Please sign in to comment.