Skip to content

Commit 2e888a5

Browse files
committed
Unbind the previous handler when a new handler is added
1 parent 528ed74 commit 2e888a5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,22 @@ define([
225225
});
226226
},
227227

228+
/**
229+
* Unbind previous form submit listener.
230+
*/
231+
unbindFormSubmit: function () {
232+
$('[data-action="add-to-wishlist"]').off('click');
233+
},
234+
228235
/**
229236
* Bind form submit.
230237
*/
231238
bindFormSubmit: function () {
232239
var self = this;
233240

241+
// Prevents double handlers and duplicate requests to add to Wishlist
242+
this.unbindFormSubmit();
243+
234244
$('[data-action="add-to-wishlist"]').on('click', function (event) {
235245
var element, params, form, action;
236246

0 commit comments

Comments
 (0)