Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jquery/validator missing in autofill.js #71

Closed
marcoveeneman opened this issue Feb 9, 2023 · 2 comments
Closed

jquery/validator missing in autofill.js #71

marcoveeneman opened this issue Feb 9, 2023 · 2 comments

Comments

@marcoveeneman
Copy link

Hi,

I was trying to use the postcode check on the customer change address form, but the autofill.js module failed to load.
componentLoadingFail {component: 'Flekto_Postcode/js/view/customer/address/autofill'} (Using version 3.1.9)

When stepping in the code it appears the following line:

validatorInstance: $('.form-address-edit').validate(),

Is causing this exception:

"TypeError: $(...).validate is not a function
    at http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/Flekto_Postcode/js/view/customer/address/autofill.js:11:56
    at Object.execCb (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/requirejs/require.js:1650:33)
    at context.execCb (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/mage/requirejs/resolver.js:156:31)
    at Module.check (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/requirejs/require.js:861:55)
    at Module.enable (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/requirejs/require.js:1143:22)
    at Module.init (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/requirejs/require.js:774:26)
    at callGetModule (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/requirejs/require.js:1170:63)
    at Object.completeLoad (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/requirejs/require.js:1544:21)
    at HTMLScriptElement.onScriptLoad (http://127.0.0.1/static/version1671735671/frontend/Vendor/theme/nl_NL/requirejs/require.js:1671:29)"

Potential fix
After fiddling around a bit it seems the following change is fixing the problem for me:
in autofill.js change this

define([
    'uiCollection',
    'uiRegistry',
    'jquery',
], function (Collection, Registry, $) {

to

define([
    'uiCollection',
    'uiRegistry',
    'jquery',
    'jquery/validate',
], function (Collection, Registry, $) {

Can you confirm this problem and that this is the correct fix? Thanks!

@JerrySmidt
Copy link
Contributor

Hello,

Sure, this fix looks correct to me. It makes sense to add because autofil.js does depend on the jQuery Validation Plugin.

I can't confirm this problem however, the jQuery validator already exists at the address edit page in my local Magento installation (version 2.4.5-p1). But for some reason it's not loaded on your side.

Thanks for reporting, I'll include the fix in the next release.

JerrySmidt added a commit to JerrySmidt/PostcodeNl_Api_Magento2 that referenced this issue Feb 9, 2023
JerrySmidt added a commit to JerrySmidt/PostcodeNl_Api_Magento2 that referenced this issue Jun 6, 2023
@marcoveeneman
Copy link
Author

Seems like this is fixed in 3.1.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants