Skip to content

Commit

Permalink
Convert payments row backbone view into JS
Browse files Browse the repository at this point in the history
Per our definition newly introduced files should be JS instead of Coffeescript.
  • Loading branch information
tvdeyen committed Dec 1, 2017
1 parent 5e813dc commit 3d135fe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Spree.Views.Payment.PaymentRow = Backbone.View.extend({
events: {
"click .js-edit": "onEdit",
"click .js-save": "onSave",
"click .js-cancel": "onCancel"
},

onEdit: function(e) {
e.preventDefault();
this.$el.addClass("editing");
},

onCancel: function(e) {
e.preventDefault();
this.$el.removeClass("editing");
},

onSave: function(e) {
var view = this;
var amount = this.$(".js-edit-amount").val();
var options = {
success: function(model, response, options) {
view.$(".js-display-amount").text(model.attributes.display_amount);
view.$el.removeClass("editing");
},
error: function(model, response, options) {
show_flash('error', response.responseJSON.error);
}
};
e.preventDefault();
this.model.save({
amount: amount
}, options);
}
});

This file was deleted.

0 comments on commit 3d135fe

Please sign in to comment.