question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mouse click to leave autonumeric field sometime could not fire jquery change event

See original GitHub issue

Current behavior

After editing value on an autoNumeric field, if using mouse to click on other place, sometimes it could not fire the jquery change event of the input field, I can repeat the same problem in about 1 out of 20 times.

However, it is ok to fire the jquery change event if using keyboard TAB key to leave the field.

I have tried using jQuery v3.2.1 and the latest v3.3.1, the same problem exists.

Expected behavior

jquery change event is expected to be fired after changing value on an autoNumeric field then leaving the field by clicking other place

Steps to reproduce the problem

  1. Use autoNumeric version <4.2.15>
  2. In the browser <Firefox> version <60.0.2> , and <Chrome> version <67.0.3396.87>
  3. On the <Windows 10> operating system
  4. Then instantiate the autoNumeric object with the following options: new AutoNumeric(domElement, { options });
  5. As in live example below

Link to live example (ie. Codepen)

https://codepen.io/mars2018/pen/xzYXJV

In the example. let’s input value 1 and value 2 first, then start testing by changing the value 1, it will calculate value 3 when value 1 is changed.

After editing the value 1, if I use mouse to click the value 2 field (or other places), sometimes it could not fire the jquery change event so the value 3 is unchanged. Please note that it is not happened very time, it happens in about 1 out of 20 times.

While using keyborad TAB to move focus to “value 2 field” after changing “value 1 field”, it is always ok.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MatiasBordoycommented, Jun 19, 2020

Hi Alexandre, i updated my autonumerics.js to the last version and the error was gone. I thought i had the last version.

Thanks for your response.

1reaction
AlexandreBonneaucommented, Jul 21, 2018

Well, I changed the code to ditch jQuery and so far it works perfectly as intended (see the updated codepen).

I feel like I’m repeating myself, but jQuery events are bugged and cannot be relied on correctly. This is not the first time it happens, and anyway you might not need jQuery 😃

For the time being I’ll close that issue. Feel free to reopen it if you think this might also affect users that do not use jQuery.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery change event not firing for input field - Stack Overflow
You can programmatically force a change event via the trigger('change') method: $('#elementID').trigger('change');. This assumes, of course, ...
Read more >
Easy Number and Currency Formatting Library - autoNumeric
autoNumeric is a useful JavaScript library for international currency formatting as well as numbers formatting.
Read more >
Event | PrimeFaces JavaScript API Docs
jQuery's event model can trigger an event by any name on an element, and it is propagated up the DOM tree to which...
Read more >
autoNumeric - Decor Plan it
autoNumeric 1.9.41 is a jQuery plugin that automatically formats currency and numbers as you type on form inputs.
Read more >
autonumeric - UNPKG
The CDN for autonumeric. ... autonumeric/dist/autoNumeric.min.js.map ... { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\t/**\n\t ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found