Skip to content

Commit

Permalink
Dispose tooltips before re-rendering or they'll persist after element…
Browse files Browse the repository at this point in the history
…s removed from DOM.
  • Loading branch information
JDutil committed Oct 3, 2018
1 parent 3010496 commit 1382b69
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/app/assets/javascripts/spree/backend/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Spree.ready(function(){
},
dataType: 'script',
success: function(response) {
el.tooltip('dispose')
el.parents("tr").fadeOut('hide', function() {
$(this).remove();
});
Expand All @@ -101,6 +102,7 @@ Spree.ready(function(){

$('body').on('click', 'a.spree_remove_fields', function() {
var el = $(this);
el.tooltip('dispose')
el.prev("input[type=hidden]").val("1");
el.closest(".fields").hide();
if (el.prop("href").substr(-1) == '#') {
Expand Down
1 change: 1 addition & 0 deletions backend/app/assets/javascripts/spree/backend/shipments.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ var ShipmentSplitItemView = Backbone.View.extend({

cancelItemSplit: function(e){
e.preventDefault();
$(e.target).tooltip('dispose')

this.shipmentItemView.removeSplit();
this.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ Spree.Views.Cart.LineItemRow = Backbone.View.extend({

onEdit: function(e) {
e.preventDefault()
$(e.target).tooltip('dispose')
this.editing = true
this.render()
},

onCancel: function(e) {
e.preventDefault();
$(e.target).tooltip('dispose')
if (this.model.isNew()) {
this.remove();
this.model.destroy();
Expand All @@ -42,6 +44,7 @@ Spree.Views.Cart.LineItemRow = Backbone.View.extend({

onSave: function(e) {
e.preventDefault()
$(e.target).tooltip('dispose')
if(!this.validate()) {
return;
}
Expand All @@ -64,6 +67,7 @@ Spree.Views.Cart.LineItemRow = Backbone.View.extend({

onDelete: function(e) {
e.preventDefault()
$(e.target).tooltip('dispose')
if(!confirm(Spree.translations.are_you_sure_delete)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Spree.Views.Order.ShipmentTracking = Backbone.View.extend({
},

onSave: function(event) {
$(event.target).tooltip('dispose')
this.editing = false;
this.model.save({
tracking: this.$('input[type="text"]').val()
Expand All @@ -31,6 +32,7 @@ Spree.Views.Order.ShipmentTracking = Backbone.View.extend({
},

onCancel: function(event) {
$(event.target).tooltip('dispose')
this.editing = false;
this.render();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Spree.Views.Order.ShippingMethod = Backbone.View.extend({
},

onSave: function(event) {
$(event.target).tooltip('dispose')
this.editing = false;
this.shippingMethodId = this.$('select').val();
this.shippingRates = new Backbone.Collection();
Expand All @@ -37,6 +38,7 @@ Spree.Views.Order.ShippingMethod = Backbone.View.extend({
},

onCancel: function(event) {
$(event.target).tooltip('dispose')
this.editing = false;
this.shippingRates = new Backbone.Collection();
this.render();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Spree.Views.Payment.PaymentRow = Backbone.View.extend({

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

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

Expand All @@ -29,6 +31,7 @@ Spree.Views.Payment.PaymentRow = Backbone.View.extend({
}
};
e.preventDefault();
$(e.target).tooltip('dispose')
this.model.save({
amount: amount
}, options);
Expand Down

0 comments on commit 1382b69

Please sign in to comment.