Skip to content

Commit

Permalink
Merge pull request #2336 from nebulab/improve-product-stock-form
Browse files Browse the repository at this point in the history
Fix action classes on admin tables
  • Loading branch information
jhawthorn authored Dec 20, 2017
2 parents d07e5bd + 94781aa commit ba0de82
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions backend/app/assets/javascripts/spree/backend/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ Spree.ready(function() {
var tr = $(this).closest('tr');
var klass = 'highlight action-' + $(this).data('action')
tr.addClass(klass)
});
$('table').on("mouseleave", 'td.actions a, td.actions button', function(){
var tr = $(this).closest('tr');
var klass = 'highlight action-' + $(this).data('action')
tr.removeClass(klass)

var observer = new MutationObserver(function(mutations) {
tr.removeClass(klass);
this.disconnect();
});
observer.observe(tr.get(0), { childList: true });

// Using .one() instead of .on() prevents multiple callbacks to be attached
// to this event if mouseentered multiple times.
$(this).one("mouseleave", function() {
tr.removeClass(klass);
observer.disconnect();
});
});
});

Expand Down

0 comments on commit ba0de82

Please sign in to comment.