jackocnr / intl-tel-input

A JavaScript plugin for entering and validating international telephone numbers. React and Vue components also included.
https://intl-tel-input.com
MIT License
7.69k stars 1.95k forks source link

TypeError: e[a] is not a function #1782

Closed sateeshmunagala closed 2 months ago

sateeshmunagala commented 2 months ago

Plugin version

v24.4.0 e.g. v24.4.0 (please try latest version)

Steps to reproduce

  1. Downloaded the latest version zip file [v24.4.0], extracted and placed in respective folders under nopcommerce - asp.net mvc project.
  2. Run the application
  3. In browser console I can see the error.

Expected behaviour

Tell us what should happen No error should be there

Actual behaviour

Tell us what actually happens Got Below error Uncaught (in promise) TypeError: e[a] is not a function at intlTelInput.min.js:16:9979 at Array.forEach () at b (intlTelInput.min.js:16:9964) at intlTelInput.min.js:16:30322

I tride to downgrade to lower version [v24.3.7] but got the same error again

Initialisation options

List any options you're using e.g. utilsScript or onlyCountries

Below are my init options

const phoneInput = window.intlTelInput(phoneInputField, { utilsScript: "~/Themes/NobleTheme/Content/js/utils.js", initialCountry: "in", autoHideDialCode: false, preferredCountries: ["in", "us", "ca", "au", "gb"], separateDialCode: true, nationalMode: true, formatOnDisplay: false, localizedCountries: { 'in': 'India' }, showSelectedDialCode: true });

Request you take a look at this issue

jackocnr commented 2 months ago

I think the problem is with the utilsScript option - you're providing a relative path, but you must provide an absolute path here. Please see the readme for more info.

You may also want to check the other initialisation options you're using with the readme - several of them are incorrect, or no longer exist etc.

ozgurozbek commented 2 months ago

Fails on let i=document.createElement(a);return t&&Object.entries(t).forEach(([n,s])=>i.setAttribute(n,s)),e&&e.appendChild(i),i},b=a=>{let{instances:t}=r;Object.values(t).forEach(e=>e[a]())... so yes, its about the options.

I've tried it without absolute path too, it throws an error on page load. In this case though, phoneInputField could also not be defined in DOM when this piece of code is running.

Fixing the path on options should fix this, otherwise a minimal reproduceable example would be good outside of NopCommerce.

jackocnr commented 2 months ago

Thanks for the confirmation @ozgurozbek. I'll close this for now, but @sateeshmunagala do let us know if that doesn't fix the issue for you.