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

Using AutoNumeric without npm #714

Open
o-alquimista opened this issue Jun 8, 2021 · 1 comment
Open

Using AutoNumeric without npm #714

o-alquimista opened this issue Jun 8, 2021 · 1 comment
Labels
💁‍♂️ Need reporter feedback A response is needed from the reporter before being able to do more

Comments

@o-alquimista
Copy link

o-alquimista commented Jun 8, 2021

I've copied the contents of the /src directory somewhere, added the missing .js extension to all imports in it, then imported it like this from another module:

import AutoNumeric from './import/autoNumeric-4.6.0/AutoNumeric.js';

To instantiate it:

let test = new AutoNumeric('.my-input-element');

But it fails with Uncaught TypeError: can't convert undefined to object. Any idea why?

Full log:

Uncaught TypeError: can't convert undefined to object
    _isPreDefinedOptionValid http://dentvida.legulas:8080/js/import/autoNumeric-4.6.0/AutoNumeric.js:1110
    _setArgumentsValues http://dentvida.legulas:8080/js/import/autoNumeric-4.6.0/AutoNumeric.js:943
    AutoNumeric http://dentvida.legulas:8080/js/import/autoNumeric-4.6.0/AutoNumeric.js:103
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:51
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:46
    <anonymous> http://dentvida.legulas:8080/js/pgto_agenda.js:4
    EventListener.handleEvent* http://dentvida.legulas:8080/js/pgto_agenda.js:3
AutoNumeric.js:1110:48
    hasOwnProperty self-hosted:2561
    _isPreDefinedOptionValid http://dentvida.legulas:8080/js/import/autoNumeric-4.6.0/AutoNumeric.js:1110
    _setArgumentsValues http://dentvida.legulas:8080/js/import/autoNumeric-4.6.0/AutoNumeric.js:943
    AutoNumeric http://dentvida.legulas:8080/js/import/autoNumeric-4.6.0/AutoNumeric.js:103
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:51
    (assíncrono: EventListener.handleEvent)
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:46
    <anonymous> http://dentvida.legulas:8080/js/pgto_agenda.js:4
    (assíncrono: EventListener.handleEvent)
    <anonymous> http://dentvida.legulas:8080/js/pgto_agenda.js:3
    InnerModuleEvaluation self-hosted:2384
    evaluation self-hosted:2335

I have also tried this:

let test = new AutoNumeric('.my-input-element', AutoNumeric.getPredefinedOptions().Brazilian);

But it fails with:

Uncaught TypeError: (intermediate value).getPredefinedOptions() is undefined
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:51
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:46
    <anonymous> http://dentvida.legulas:8080/js/pgto_agenda.js:4
    EventListener.handleEvent* http://dentvida.legulas:8080/js/pgto_agenda.js:3
pgto_agenda.js:51:57
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:51
    (assíncrono: EventListener.handleEvent)
    formaPagamento http://dentvida.legulas:8080/js/pgto_agenda.js:46
    <anonymous> http://dentvida.legulas:8080/js/pgto_agenda.js:4
    (assíncrono: EventListener.handleEvent)
    <anonymous> http://dentvida.legulas:8080/js/pgto_agenda.js:3
    InnerModuleEvaluation self-hosted:2384
    evaluation self-hosted:2335
@AlexandreBonneau
Copy link
Member

Try importing main.js instead

@AlexandreBonneau AlexandreBonneau added the 💁‍♂️ Need reporter feedback A response is needed from the reporter before being able to do more label May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💁‍♂️ Need reporter feedback A response is needed from the reporter before being able to do more
Projects
None yet
Development

No branches or pull requests

2 participants