@@ -22,7 +22,6 @@ define([
2222 /** @inheritdoc */
2323 _create : function ( ) {
2424 this . _bind ( ) ;
25- this . bindFormSubmit ( false ) ;
2625 } ,
2726
2827 /**
@@ -64,6 +63,12 @@ define([
6463 isFileUploaded = false ,
6564 self = this ;
6665
66+ if ( event . handleObj . selector == this . options . qtyInfo ) { //eslint-disable-line eqeqeq
67+ this . _updateAddToWishlistButton ( { } ) ;
68+ event . stopPropagation ( ) ;
69+
70+ return ;
71+ }
6772 $ ( event . handleObj . selector ) . each ( function ( index , element ) {
6873 if ( $ ( element ) . is ( 'input[type=text]' ) ||
6974 $ ( element ) . is ( 'input[type=email]' ) ||
@@ -84,7 +89,9 @@ define([
8489 }
8590 } ) ;
8691
87- this . bindFormSubmit ( isFileUploaded ) ;
92+ if ( isFileUploaded ) {
93+ this . bindFormSubmit ( ) ;
94+ }
8895 this . _updateAddToWishlistButton ( dataToAdd ) ;
8996 event . stopPropagation ( ) ;
9097 } ,
@@ -183,41 +190,33 @@ define([
183190 /**
184191 * Bind form submit.
185192 */
186- bindFormSubmit : function ( isFileUploaded ) {
193+ bindFormSubmit : function ( ) {
187194 var self = this ;
188195
189- $ ( '[data-action="add-to-wishlist"]' ) . off ( 'click' ) . on ( 'click' , function ( event ) {
196+ $ ( '[data-action="add-to-wishlist"]' ) . on ( 'click' , function ( event ) {
190197 var element , params , form , action ;
191198
192- if ( ! $ ( $ ( self . options . qtyInfo ) . closest ( 'form' ) ) . valid ( ) ) {
193- event . stopPropagation ( ) ;
194- event . preventDefault ( ) ;
199+ event . stopPropagation ( ) ;
200+ event . preventDefault ( ) ;
195201
196- return ;
202+ element = $ ( 'input[type=file]' + self . options . customOptionsInfo ) ;
203+ params = $ ( event . currentTarget ) . data ( 'post' ) ;
204+ form = $ ( element ) . closest ( 'form' ) ;
205+ action = params . action ;
206+
207+ if ( params . data . id ) {
208+ $ ( '<input>' , {
209+ type : 'hidden' ,
210+ name : 'id' ,
211+ value : params . data . id
212+ } ) . appendTo ( form ) ;
197213 }
198214
199- if ( isFileUploaded ) {
200- element = $ ( 'input[type=file]' + self . options . customOptionsInfo ) ;
201- params = $ ( event . currentTarget ) . data ( 'post' ) ;
202- form = $ ( element ) . closest ( 'form' ) ;
203- action = params . action ;
204-
205- if ( params . data . id ) {
206- $ ( '<input>' , {
207- type : 'hidden' ,
208- name : 'id' ,
209- value : params . data . id
210- } ) . appendTo ( form ) ;
211- }
212-
213- if ( params . data . uenc ) {
214- action += 'uenc/' + params . data . uenc ;
215- }
216-
217- $ ( form ) . attr ( 'action' , action ) . submit ( ) ;
218- event . stopPropagation ( ) ;
219- event . preventDefault ( ) ;
215+ if ( params . data . uenc ) {
216+ action += 'uenc/' + params . data . uenc ;
220217 }
218+
219+ $ ( form ) . attr ( 'action' , action ) . submit ( ) ;
221220 } ) ;
222221 }
223222 } ) ;
0 commit comments