@@ -25,24 +25,34 @@ $_paymentBlock = $this->getLayout()->getBlock('checkout.onepage.payment');
25
25
</ol>
26
26
<script>
27
27
require([
28
- "jquery",
29
- "mage/mage"
30
- ], function($){
28
+ "underscore",
29
+ "accordion",
30
+ "opcOrderReview",
31
+ ], function(_, accordion, opcOrderReview){
31
32
'use strict';
32
33
33
- $(document).ready(function() {
34
- $('#checkoutSteps').mage('accordion',{
35
- 'collapsibleElement' : ' > li',
36
- 'openedState' : 'active'
37
- }).mage('opcOrderReview', $.extend({
38
- 'checkoutAgreements': '#checkout-agreements',
39
- 'checkoutProgressContainer': '#checkout-progress-wrapper',
40
- 'methodDescription': '.items'
41
- },
42
- <?php echo $ this ->helper ('Magento\Core\Helper\Data ' )->jsonEncode ($ _paymentBlock ->getOptions ()); ?>
43
- ));
44
- });
34
+ /**
35
+ * @todo refactor opcCheckoutMethod
36
+ *
37
+ * Initializiation of this components can't be moved to a data-mage-init attribute
38
+ * due to dependencies between instances of opcCheckoutMethod and mage.accordion.
39
+ * Thus initializiation has to be synchronyous.
40
+ */
41
+ var elem = document.getElementById('checkoutSteps'),
42
+ opcConfig;
45
43
44
+ opcConfig = _.extend({
45
+ 'checkoutAgreements': '#checkout-agreements',
46
+ 'checkoutProgressContainer': '#checkout-progress-wrapper',
47
+ 'methodDescription': '.items'
48
+ },<?php echo $ this ->helper ('Magento\Core\Helper\Data ' )->jsonEncode ($ _paymentBlock ->getOptions ()); ?> );
49
+
50
+ accordion({
51
+ 'collapsibleElement': ' > li',
52
+ 'openedState': 'active'
53
+ }, elem);
54
+
55
+ opcOrderReview(opcConfig, elem);
46
56
});
47
57
</script>
48
58
</div>
0 commit comments