2

this my checkout_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Asiantech_Postcode::css/jquery.Thailand.min.css"/>
    </head>
    <body>
        <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="autocomplete" xsi:type="array">
                                    <item name="sortOrder" xsi:type="string">0</item>
                                    <item name="component" xsi:type="string">Vendor_Module/js/autocomplate</item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

autocomplete.js

define([
'jquery',
'uiComponent',
'Magento_Checkout/js/checkout-data',
'uiRegistry',
], function (
$,
Component,
checkoutData,
uiRegistry,
) {
"use strict";   
console.log(uiRegistry.get('checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset.postcode'));

return Component.extend({
    /**
     * Initialization method
     */
    initialize: function () {
        this._super();
    }
  });
});

but my result is `undefined',what's wrong with this component ?

4
  • You misspelled autocomplete.
    – P S
    Commented Nov 29, 2017 at 6:54
  • I corrected the spelling but not the main issue, because this file must be run after $(window).load(fn)
    – nv trong
    Commented Nov 30, 2017 at 4:31
  • okay. have you got you solution. If yes then I would love to see it.
    – P S
    Commented Nov 30, 2017 at 5:36
  • Then update your question.
    – P S
    Commented Nov 30, 2017 at 9:42

1 Answer 1

0

@Anime i get new file loader.js this code :

define(['jquery'],function ($) {    
    var loaded_def = $.Deferred();
    $(window).ready(function () {
        loaded_def.resolve();        
    });
    return loaded_def.promise();
}); 

and define in autocomplete.js this code

define([
...
'vendor_module/js/loader'
], function (
$,
...
Loader
) {
"use strict";
Loader.done(function(){
console.log(uiRegistry.get('checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset.postcode').uid);
});
return Component.extend({
/**
 * Initialization method
 */
initialize: function () {
    this._super();
}
});
});

it run !!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.