File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ define(
25
25
) {
26
26
'use strict' ;
27
27
28
+ // State of PayPal module initialization
29
+ var clientInit = false ;
30
+
28
31
return Component . extend ( {
29
32
30
33
defaults : {
@@ -93,15 +96,26 @@ define(
93
96
* @returns {Object }
94
97
*/
95
98
initClient : function ( ) {
99
+ var selector = '#' + this . getButtonId ( ) ;
100
+
96
101
_ . each ( this . clientConfig , function ( fn , name ) {
97
102
if ( typeof fn === 'function' ) {
98
103
this . clientConfig [ name ] = fn . bind ( this ) ;
99
104
}
100
105
} , this ) ;
101
106
102
- domObserver . get ( '#' + this . getButtonId ( ) , function ( ) {
103
- paypalExpressCheckout . checkout . setup ( this . merchantId , this . clientConfig ) ;
104
- } . bind ( this ) ) ;
107
+ if ( ! clientInit ) {
108
+ domObserver . get ( selector , function ( ) {
109
+ paypalExpressCheckout . checkout . setup ( this . merchantId , this . clientConfig ) ;
110
+ clientInit = true ;
111
+ domObserver . off ( selector ) ;
112
+ } . bind ( this ) ) ;
113
+ } else {
114
+ domObserver . get ( selector , function ( ) {
115
+ $ ( selector ) . on ( 'click' , this . clientConfig . click ) ;
116
+ domObserver . off ( selector ) ;
117
+ } . bind ( this ) ) ;
118
+ }
105
119
106
120
return this ;
107
121
} ,
You can’t perform that action at this time.
0 commit comments