intl-tel-input: intlTelInput is not a function

Hello, I know this issue has been reported many times but none of the answers have been able to fix my problem.

Steps to reproduce

Same as the Github ones, both css and js imports (that is the right path): <link rel="stylesheet" href="./node_modules/intl-tel-input/src/css/intlTelInput.css"> <script src="./node_modules/intl-tel-input/src/js/utils.js"></script> My input is generated dynamically with a ‘tel’ type I then check the type and execute the following code: if (columnData.forminfo.fields[u].inputtype === "tel") { var input = $("#"+columnData.forminfo.fields[u].inputid); window.intlTelInput(input); } But I also tried this (with the utils import too): var input = document.querySelector("#"+columnData.forminfo.fields[u].inputid); var iti = intlTelInput(input, { utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@16.0.3/build/js/utils.js", }); }

Expected behaviour

I should have had my input created with the flag version.

Actual behaviour

I get an error: ‘intlTelInput is not a function’.

Initialisation options

I put my code above.

If I don’t use the window. in the first code, I get a ‘intlTelInput is not defined’ if it can help.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

I’m sorry but if you’re having problems with basic JavaScript operations like selecting an element, then I don’t have time to provide support for that - I would recommend you ask on StackOverflow. best of luck.